websocket + History 路由
user root; worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; upstream picamp_server { server 127.0.0.1:8080; } server { listen 80; server_name 192.168.21.35; location / { alias /root/dist/; try_files $uri $uri/ /index.html; expires off; }
location /api/v1 { proxy_pass http://picamp_server; client_max_body_size 1024m; proxy_set_header Origin ''; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } map $http_upgrade $connection_upgrade { default upgrade; '' close; } server { listen 54321; server_name 192.168.21.35; location /websocket { proxy_pass http://127.0.0.1:12345; proxy_read_timeout 30m; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; proxy_set_header X-Real-IP $remote_addr; } } }