nginx +tomcat 多域名共享端口
- http{
- upstream test1 {
- server 192.168.0.1:81 weight=1;
- }
- #第二个网站的
- upstream test2 {
- server 192.168.1.1:8080 ;
- }
- #同一服务器转发2个不同域名进行负载均衡
- server
- {
- listen 80;
- server_name test1; test1.aaa.com
- location / {
- index index.html index.jsp;
- #这里的proxy_pass转发的是upstream的名字www.aaa.com
- proxy_pass http://test1;
- proxy_set_header X-Real-IP $remote_addr;
- client_max_body_size 100m;
- }
- }
- server
- {
- listen 80;
- server_name www.test2.com;
- location / {
- index index.html index.jsp;
- proxy_pass http://test2;
- proxy_set_header X-Real-IP $remote_addr;
- client_max_body_size 100m;
- }
- }
- #######下面是直接赚了一个静态网站
-
server
-
{
-
listen 80 ;
- server_name test.com;
- charset UTF-8;
- root /website/vshopxx;
- location /{
- index index.html;
-
}
-
error_page 500 502 503 504 /50x.html;
-
location = /50x.html {
-
root html;}
-
}
- #########
-
server {
listen 80 ;
server_name coin.vip www.coin.vip;
charset UTF-8;
root /website/index/;
location / {
# index index.html;
# root /website/index;
index index.html;
try_files $uri $uri/ /index.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
在nginx.conf 中添加如上
我是用yum装的nginx,默认的配置文件在usr\...\nginx.conf 不是、/etc/nginx/nginx.conf!!!!, 启动的时候用nginx -c /etc/nginx/nginx.conf 才会按照新的配置文件启动
参考链接 http://www.linuxde.net/2012/06/11006.html
http://www.nginx.cn/doc/
整个

浙公网安备 33010602011771号