一、这个可以给直接使用的,替换应用集群ip端口,和反向代理名称即可
#
# ngixn 配置文件
#
#user nobody;
worker_processes auto;
#错误日志配置
#error_log logs/error.log;
error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
#工作进程最大连接数,注意系统单进程最大连接数限制,以及系统总句柄数限制。建议 8192
events {
worker_connections 10240;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
client_max_body_size 1000m;
#keepalive_timeout 0;
keepalive_timeout 65;
#############################
# 下面是应用集群
#############################
upstream abcdtomcat{
server 192.168.1.100:8080 weight=10;
server 192.168.1.101:8080 weight=10;
}
#gzip on;
server {
listen 80;
server_name 192.168.1.200;
####################################
# 以下填写各应用相关的反向代理信息
####################################
#
# 例如:http://192.168.1.200/adcd/index.do
location /abcd {
proxy_set_header Host $http_host;
proxy_pass http://abcdtomcat/abcd;
proxy_redirect default;
proxy_set_header X-Real-IP $remote_addr;
}
###################################
#资源目录静态文件代理
###################################
#location /static {
# root /usr/local/staticfile/;
#}
#静态文件拦截,这里配置了abcd的,如果不需要请将这块区域注释。去掉zbcd限制,可以对所有应用的静态资源拦截。
location ~* ^/abcd/.*(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css)$ {
root /usr/local/staticfile/;
#浏览器缓存时间
expires 7d;
}
location / {
root html;
index index.html index.htm;
}
location .~/\. {
deny all;
#关闭access log,否则每日日志大小几十G
access_log off;
log_not_found off;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}