figt to nginx

This commit is contained in:
nitros 2025-05-02 00:30:18 +07:00
parent 0eb48f41d3
commit be1c1358de
4 changed files with 12 additions and 15 deletions

View File

@ -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

View File

@ -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

View File

@ -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))

View File

@ -51,15 +51,11 @@ 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/;
@ -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$ {