figt to nginx
This commit is contained in:
parent
0eb48f41d3
commit
be1c1358de
@ -62,8 +62,8 @@ export default defineComponent({
|
|||||||
console.log(wurl)
|
console.log(wurl)
|
||||||
|
|
||||||
const connectWebSocket = () => {
|
const connectWebSocket = () => {
|
||||||
ws = new WebSocket(`ws://${wurl}:8080/ws`)
|
ws = new WebSocket(`ws://${wurl}/go/ws`)
|
||||||
//ws = new WebSocket(`ws://127.0.0.1:8080/ws`)
|
//ws = new WebSocket(`ws://127.0.0.1:8080/go/ws`)
|
||||||
ws.onmessage = (event) => {
|
ws.onmessage = (event) => {
|
||||||
const response = JSON.parse(event.data)
|
const response = JSON.parse(event.data)
|
||||||
const value = response.value
|
const value = response.value
|
||||||
|
|||||||
7
go.mod_
7
go.mod_
@ -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
|
|
||||||
2
main.go
2
main.go
@ -53,7 +53,7 @@ func main() {
|
|||||||
http.Handle("/", fs)
|
http.Handle("/", fs)
|
||||||
|
|
||||||
// WebSocket endpoint
|
// WebSocket endpoint
|
||||||
http.HandleFunc("/ws", handleWebSocket)
|
http.HandleFunc("/go/ws", handleWebSocket)
|
||||||
|
|
||||||
log.Println("Server starting on :8080...")
|
log.Println("Server starting on :8080...")
|
||||||
log.Fatal(http.ListenAndServe(":8080", nil))
|
log.Fatal(http.ListenAndServe(":8080", nil))
|
||||||
|
|||||||
@ -51,16 +51,12 @@ server {
|
|||||||
try_files $uri $uri/ =404;
|
try_files $uri $uri/ =404;
|
||||||
}
|
}
|
||||||
location /go/ {
|
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_pass http://127.0.0.1:8080/;
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
rewrite ^/git/(.*) /$1 break;
|
}
|
||||||
}
|
|
||||||
location /assets/ {
|
location /assets/ {
|
||||||
proxy_pass http://127.0.0.1:8080/assets/;
|
proxy_pass http://127.0.0.1:8080/assets/;
|
||||||
proxy_set_header Host $host;
|
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-For $proxy_add_x_forwarded_for;
|
||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
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
|
# pass PHP scripts to FastCGI server
|
||||||
#
|
#
|
||||||
#location ~ \.php$ {
|
#location ~ \.php$ {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user