linux 部署nginx----端口轉發

1、解壓安裝html

tar zxvf nginx-1.9.6.tar.gz 
 cd nginx-1.9.6
./configure --with-http_stub_status_module --with-http_ssl_module
make
make install

2、啓動nginx

/usr/local/nginx/sbin/nginx

 

 3、修改配置文件tomcat

 vi /opt/nginx-1.9.6/conf/nginx.conf 

端口轉發負載均衡

server {
       listen       83;
       server_name  http://127.0.0.1:8080;spa

        #charset koi8-r;code

        access_log  logs/83.log  main;server

        location / {
                        proxy_pass http://127.0.0.1:8080;
                        proxy_pass_header Server;
                        proxy_set_header Host   $host:83;
                        proxy_set_header X-Real-IP $remote_addr;
                        proxy_set_header X-Scheme $scheme;
            }
     }htm

和上面一個 server 並聯寫一個。blog

若是要負載均衡,再寫一個upstreamssl

upstream tomcat_server{
server 127.0.0.1:8080;
}

和server 並聯

server 裏面寫一句 便可

        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_pass http://tomcat_server;

 

4、檢查配置文件與啓動狀況

 

 /usr/local/nginx/sbin/nginx -t

啓動見下面
ps -ef |grep nginx

 

5、啓動、中止、重啓

中止:

/usr/local/nginx/sbin/nginx -s stop

啓動:

/usr/local/nginx/sbin/nginx

重啓:

/usr/local/nginx/sbin/nginx -s reload 

 參考文章:

http://selfcontroller.iteye.com/blog/1879862

http://www.cnblogs.com/bluewelkin/p/4193725.html

http://www.ttlsa.com/nginx/use-nginx-proxy/

相關文章
相關標籤/搜索