Nginx配置

nginx.conf

 

#配置负载均衡
# upstream www_pools {
# ip_hash;
# server www.jinlin1.com:8080;
# server www.jinlin2.com:8080;
# }

upstream jvm_web1 {
server www.jinlin1.com:8080;
}

upstream jvm_web2 {
server www.jinlin2.com:8081;
}

server {
listen 80;
server_name www.jinlin1.com;

#charset koi8-r;

#access_log logs/host.access.log main;

#location / {
#配置反向代理
# proxy_pass http://www_pools;
#配置头信息,告诉nginx是谁在访问
# proxy_set_header Host $host;
# proxy_set_header X-Forward-For $remote_addr;
# root html;
# index index.html index.htm;
#}

location / {
proxy_pass http://jvm_web1;
proxy_set_header Host $host;
proxy_set_header X-Forward-For $remote_addr;
}

location ~* \.(html|js|txt|css)$ {
root html;
}

location ~* \.(jsp) {
proxy_pass http://jvm_web1;
proxy_set_header Host $host;
proxy_set_header X-Forward-For $remote_addr;
}


#location ~* \.(jpg|png|gif)$ {

# proxy_pass http://www_pools;
# proxy_set_header Host $host;
# proxy_set_header X-Forward-For $remote_addr;

#配置白名单
# valid_referers 192.168.58.128;

#防盗技术
# if ($invalid_referer) {

# return 403;

# }
#}

#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;
}

server {
listen 80;
server_name www.jinlin2.com;
location / {
proxy_pass http://jvm_web2;
proxy_set_header Host $host;
proxy_set_header X-Forward-For $remote_addr;
}
#如果是静态页面,则不通过tomcat,nginx自己处理静态页面
location ~* \.(html|js|txt|css)$ {
root html;
}
}

posted @ 2018-10-27 15:44  小狗吃月亮  阅读(142)  评论(0编辑  收藏  举报