nginx如何反向代理到其他公网IP

  1. 代理服务器A,IP为192。168.31.3,配置nginx。
  2. 网站1,部署在与A同一局域网的服务器,地址为http://192.168.31.4:8180
  3. 网站2,部署在其他服务器,与服务器A不是同一局域网,网站地址:http://139.139.8.34:8182(公网)

nginx配置

server {
    listen 443 http2 ssl;
    server_name  test1.xxx.com;
    location / {
        proxy_pass http://192.168.31.4:8180;
    }
}

server {
    listen 443 http2 ssl;
    server_name  test2.xxx.com;
    location / {
        proxy_pass http://139.139.8.34:8182;
    }
}

网站1通过https://test1.xxx.com可以访问,但网站2通过https://test2.xxx.com无法访问(通过http://139.139.8.34:8182可以访问)

请问需要如何配置才能使得网站2可以通过https://test2.xxx.com访问

阅读 5.3k
2 个回答
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题