diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 20afc39..4b39a95 100755 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -62,8 +62,8 @@ export default defineComponent({ console.log(wurl) const connectWebSocket = () => { - ws = new WebSocket(`ws://${wurl}:8080/ws`) - //ws = new WebSocket(`ws://127.0.0.1:8080/ws`) + ws = new WebSocket(`ws://${wurl}/go/ws`) + //ws = new WebSocket(`ws://127.0.0.1:8080/go/ws`) ws.onmessage = (event) => { const response = JSON.parse(event.data) const value = response.value diff --git a/go.mod_ b/go.mod_ deleted file mode 100755 index 3fbc6b0..0000000 --- a/go.mod_ +++ /dev/null @@ -1,7 +0,0 @@ -module websocket-server - -go 1.21 - -require github.com/gorilla/websocket v1.5.1 - -require golang.org/x/net v0.17.0 // indirect diff --git a/main.go b/main.go index 63a22ec..f765bb1 100755 --- a/main.go +++ b/main.go @@ -53,7 +53,7 @@ func main() { http.Handle("/", fs) // WebSocket endpoint - http.HandleFunc("/ws", handleWebSocket) + http.HandleFunc("/go/ws", handleWebSocket) log.Println("Server starting on :8080...") log.Fatal(http.ListenAndServe(":8080", nil)) diff --git a/nginx/default b/nginx/default index 56e14d8..b367c5c 100644 --- a/nginx/default +++ b/nginx/default @@ -51,16 +51,12 @@ server { try_files $uri $uri/ =404; } location /go/ { - #rewrite ^ $request_uri; - #rewrite ^/git(/.*) $1 break; - #proxy_pass http://127.0.0.1:8080$uri; proxy_pass http://127.0.0.1:8080/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; - rewrite ^/git/(.*) /$1 break; - } + } location /assets/ { proxy_pass http://127.0.0.1:8080/assets/; proxy_set_header Host $host; @@ -68,6 +64,14 @@ server { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } + location /go/ws { # is important here no slash in the end + proxy_pass http://127.0.0.1:8080/go/ws; # and here no slash in the end + + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + } + # pass PHP scripts to FastCGI server # #location ~ \.php$ {