码迷,mamicode.com
首页 > 其他好文 > 详细

测试部署nginx

时间:2015-08-05 18:07:23      阅读:168      评论:0      收藏:0      [点我收藏+]

标签:

1、已经安装了nginx

2、修改tomcat端口号为10081(可随意)

3 修改nginx的nginx.config  如下:

 upstream apiserver {
           ip_hash;
           server 121.41.76.50:10081;
    }
    upstream consoleserver {
           ip_hash;
           server 121.41.76.50:10081;
    }

    server {
       listen   80;
       server_name:121.41.76.50;
       #charset koi8-r;
       #access_log logs/host.access.log main;
       location /console {
                proxy_pass http://consoleserver;
                #proxy setting
                 proxy_redirect     off;
                 proxy_set_header   Host             $host;
                 proxy_set_header   X-Real-IP        $remote_addr;
                 proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
                 #size limits
                 client_max_body_size             50m;
                 client_body_buffer_size        256k;

       }
        location /down {# /后面紧跟down 不能有空格
                proxy_pass http://consoleserver;
                 #proxy setting
                 proxy_redirect     off;
                 proxy_set_header   Host             $host;
                 proxy_set_header   X-Real-IP        $remote_addr;
                 proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
                 #size limits
                 client_max_body_size             50m;
                 client_body_buffer_size        256k;

        }
        location /api {
                proxy_pass http://apiserver;
                proxy_redirect     off;
                proxy_set_header   Host             $host;
                proxy_set_header   X-Real-IP        $remote_addr;
                proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
                client_max_body_size             50m;
                client_body_buffer_size        256k;

        }
    }

 /usr/local/nginx/sbin/nginx -t     检测配置文件是否配置成功

 /usr/local/nginx/sbin/nginx -s reload   热重启

 

测试部署nginx

标签:

原文地址:http://www.cnblogs.com/widow/p/4705160.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!