问题:在内网服务器中用nginx部署了vue项目,再将外网域名与内网IP做了映射。 访问内网IP:PORT 成功进入 访问域名:PORT 无法进入
例:内网ng地址:123.12.1.2:9000 通过这个可以访问到vue页面 将此ip与外网www.abc.com:8006做映射,无法通过www.abc.com:8006进入
原来的nginx.conf worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; server { listen 9000; location ~ .*(\.)+.*$ { root dist; index index.html; } location / { proxy_pass http://xx.xx.xxx.xx:8093$request_uri; } } } 修改后的nginx.conf worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; server { listen 9000; location ~ .*(\.)+.*$ { root dist; index index.html; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location / { proxy_pass http://xx.xx.xxx.xx:8093$request_uri; } } }加上了
proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;成功访问
