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

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

成功访问

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值