`
N295797186
  • 浏览: 8284 次
  • 性别: Icon_minigender_1
  • 来自: 大连
文章分类
社区版块
存档分类
最新评论

nginx实现同一端口url转发到多个端口和服务器备份(公司附件无法上传)

 
阅读更多
第一步:上传文件服务器

1、 在服务器根目录创建nginx文件夹,上传 nginx-1.3.15.tar.gz 和 nginx.sh到

nginx文件夹下



2、 解压 nginx-1.3.15.tar.gz

第二步:安装文件

1、 进入/nginx/nginx-1.3.15目录下

2、 分别执行下列命令安装软件:(安装默认目录/usr/local/nginx)

./configure

make

make install

第三步:修改配置文件

1、 进入/usr/local/nginx/conf目录修改nginx.conf文件

2、 修改内容说明:

红色部分为添加的代码

“80”为 10.200.130.71服务器端口号

通过访问服务器http:// 100.200.130.79:80/test可以调整到http:// 100.200.130.79:8088/test



server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

       #access_log  logs/host.access.log  main;

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

location /test{
          proxy_set_header X-Forwarded-Host $host;
          proxy_set_header X-Forwarded-Server $host;
          proxy_set_header X-Forwarded-For     $proxy_add_x_forwarded_for;
          proxy_pass http:// 100.200.130.79:8088/test(转发服务器url);
        }

#error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

     }

第四步:设置nginx服务

1、 将/nginx 下复制nginx.sh到/etc/init.d/nginx下

(执行 cp nginx.sh /etc/init.d/nginx)

2、 将nginx添加为可执行服务(执行chmod u+x /etc/init.d/nginx  

查 看nginx是否添加成功执行 ll /etc/init.d/nginx)

3、 添加到启动服务器时nginx服务默认启动

(执行chkconfig --add nginx

chkconfig nginx on
chkconfig --list



    4、启动nginx服务。       

(启停nginx服务命令:

service nginx start

service nginx stop)
分享到:
评论
发表评论

文章已被作者锁定,不允许评论。

相关推荐

Global site tag (gtag.js) - Google Analytics