VPS侦探论坛

 找回密码
 注册
查看: 3320|回复: 2

lnmpa怎么做请求转发?

[复制链接]
发表于 2016-8-25 13:22:16 | 显示全部楼层 |阅读模式

我服务器装了lnmpa1.2的版本.现在有个需求.假设我现在部署了一个网站,用的域名是123.bb.com.然后要把对123.bb.com/path的请求转发到123.cc.com:7700上,那我在nginx里该怎么配置?目前在nginx配置文件的server段里加了下面的代码,但是没有效果.
请问要实现上面的需求,该怎么配置nginx文件?

        location /lctong {
            root   html;
            index  index.html index.htm;

      proxy_pass  http://123.cc.com:7700;

      #proxy_pass  http://localhost:8080;

      #proxy_pass  http://192.168.100.125:8080;
            proxy_http_version 1.1;
            proxy_redirect    off;
            proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;
            proxy_set_header  X-Real-IP  $remote_addr;
            proxy_set_header  Host $http_host;
        }
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 2016-8-25 13:52:33 | 显示全部楼层


搞定了...原来是我改错文件了.....
应该要改vhost里面相应域名对应的文件....
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
发表于 2016-8-25 14:00:59 | 显示全部楼层

[root@localhost]#cat 123.bb.conf
server {
      listen              80;
      server_name     123.bb.com;
      location / {
            root   html/bb;
            index  index.html index.htm;
        }
       rewrite ^(.*) /path http://123.cc.com:7700 break;
}

[root@localhost]#cat 123.cc.conf
server {
      listen              80;
      server_name     123.cc.com;
      location / {
            root   html/cc;
            index  index.html index.htm;
         }
}

[ 本帖最后由 GIN 于 2016-8-25 14:02 编辑 ]
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-4-20 11:30 , Processed in 0.026070 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表