nginx部署vue项目,内外网映射后访问不到 您所在的位置:网站首页 手机外网服务器地址ip nginx部署vue项目,内外网映射后访问不到

nginx部署vue项目,内外网映射后访问不到

2024-06-29 19:28| 来源: 网络整理| 查看: 265

问题:在内网服务器中用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;

成功访问



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有