zcrself
V2EX  ›  问与答

求助! 如何实现单网站代理转发

  •  
  •   zcrself · May 14, 2015 · 2025 views
    This topic created in 4105 days ago, the information mentioned may be changed or developed.

    有两个服务器,都有公网ip或者A服务器有一个公网ip和一个私有ip,B服务器只有一个私网ip
    A服务器ip: 13.13.13.227
    B服务器ip: 13.13.13.228

    B服务器架架设web服务,比如www.123.com,这个服务只有A服务器才能访问。
    如何实现浏览器(比如ie)访问A服务器的8080端口,返回B服务器的这个网站?
    A服务器如何设置?

    1.浏览器访问http://13.13.13.227:8080
    2.A服务器收到浏览器request,去访问B服务器的web服务http://www.123.com
    3.把访问的结果返给浏览器

    6 replies    2015-05-14 13:59:21 +08:00
    shunai
        1
    shunai  
       May 14, 2015
    A上搞个nginx,设置proxy_pass 指向B的web服务
    shunai
        2
    shunai  
       May 14, 2015   ❤️ 1
    A 装个nginx,在/etc/nginx/sites-available/default配置server

    server {
    listen 80;
    root /usr/share/nginx/html;
    index index.html index.htm;
    server_name www.123.com 123.com;
    location / {
    proxy_pass http://13.13.13.228:5555/;
    proxy_redirect default;
    }

    }

    nginx reload
    9hills
        3
    9hills  
       May 14, 2015
    这个名词叫反向代理,搜一下
    imn1
        4
    imn1  
       May 14, 2015
    打个隧道就行了
    zcrself
        5
    zcrself  
    OP
       May 14, 2015
    你的回复完美地解决了我的问题,如果ngix换成apache,如何设置?
    其中这一行 proxy_pass http://13.13.13.228:5555/; 端口5555是nginx的端口吗? 从没用过nginx
    zcrself
        6
    zcrself  
    OP
       May 14, 2015
    https反向代理如何实现
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   896 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 19:06 · PVG 03:06 · LAX 12:06 · JFK 15:06
    ♥ Do have faith in what you're doing.