【发布时间】:2018-09-21 07:53:33
【问题描述】:
- NGINX - 位于 10.10.10.1
- LAMP - 坐在 172.168.1.1 上,有 phpwebsockets。它在 http://172.168.1.1:8080 上侦听,并且在 http://172.168.1.1:8080/ws 上有 ws 文件夹
Nginx 应该以这种方式转发请求。
NGINX ---> LAMP Websocket
http://10.10.10.1/randomstring/ --> https://10.10.10.1/randomstring/ --> http://172.168.1.1:8080
当前的 /conf.d/internal.conf nginx 配置文件是
server {
listen 80;
server_name 172.168.1.1;
return 301 https://$host$request_uri; #redirect to self with https
}
server {
listen 443 ssl;
server_name 172.168.1.1;
root /var/www/nginx/;
index index.html;
proxy_cache one;
location /ws {
proxy_pass http://172.168.1.1:8080;
# this magic is needed for WebSocket
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
}
location / {
proxy_pass http://172.168.1.1:8080;
}
}
我无法转发到 /randomstring ,它适用于没有 'randomstring' 的情况。
【问题讨论】:
-
对任何人有帮助吗?
标签: nginx websocket nginx-location nginx-reverse-proxy