nginx 动静分离配置

nginx 动静分离配置

静态匹配 location ~* \.(htm|html|js|gif|ico|json|swf|css|ftl|vm|png|jpg|map|xml|cur)$ 
动态匹配:
location ~ ^/call/{
proxy_pass http://dynamic-web;
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 20m;
proxy_connect_timeout 300;
proxy_send_timeout 300;
proxy_read_timeout 300;
client_body_buffer_size 128k;
} 
location ~ .*\.(php|jsp|cgi)?$ {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://dynamic-web;
}
静态发布
server {
listen 80;
server_name www.allinmd.cn;
#server_name 10.170.178.205;
index index.html index.htm;
#index index-ssl.html;
root /data/static-resource;
error_page 404 = https://www.allinmd.cn/v2/pages/not_found.html;
location ~ .*(|\.html|htm|js|json|ftl|vm){
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location ~ ^/WEB-INF/ {
deny all;
}
access_log /usr/local/nginx/logs/static.localhost.log access;
}
server {
listen 80;
listen 443 ssl;
ssl_certificate ../sslkey/1__.allinmd.cn_bundle.crt;
ssl_certificate_key ../sslkey/2__.allinmd.cn.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ALL:!DH:!EXPORT:!RC4:+HIGH:+MEDIUM:-LOW:!aNULL:!eNULL; ssl_prefer_server_ciphers on;
server_name img00.allinmd.cn;
index index.html index.htm index.jsp; # root /data/static-resource/image/img00;
root /data/static-resource/v2/image/img00; # error_page 404 = http://www.allinmd.cn;
location ~ \.(gif|jpg|jpeg|png|bmp|ico)$ {
expires 2d;
}
location ~ ^/WEB-INF/ {
deny all;
}
access_log /usr/local/nginx/logs/static.localhost.log access;
}
server {
listen 80;
listen 443 ssl;
ssl_certificate ../sslkey/1__.allinmd.cn_bundle.crt;
ssl_certificate_key ../sslkey/2__.allinmd.cn.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ALL:!DH:!EXPORT:!RC4:+HIGH:+MEDIUM:-LOW:!aNULL:!eNULL; ssl_prefer_server_ciphers on;
server_name img01.allinmd.cn;
root /data/static-resource/image/img01; # error_page 404 = http://www.allinmd.cn;
location ~ \.(gif|jpg|jpeg|png|bmp|ico)$ {
expires 2d;
}
location ~ ^/WEB-INF/ {
deny all;
}
access_log /usr/local/nginx/logs/static.localhost.log access;
}
server {
listen 80;
listen 443 ssl;
ssl_certificate ../sslkey/1__.allinmd.cn_bundle.crt;
ssl_certificate_key ../sslkey/2__.allinmd.cn.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ALL:!DH:!EXPORT:!RC4:+HIGH:+MEDIUM:-LOW:!aNULL:!eNULL; ssl_prefer_server_ciphers on;
server_name img02.allinmd.cn;
root /data/static-resource/image/img02; # error_page 404 = http://www.allinmd.cn;
location ~ \.(gif|jpg|jpeg|png|bmp|ico)$ {
expires 2d;
}
location ~ ^/WEB-INF/ {
deny all;
}
access_log /usr/local/nginx/logs/static.localhost.log access;
}
server {
listen 80;
listen 443 ssl;
ssl_certificate ../sslkey/1__.allinmd.cn_bundle.crt;
ssl_certificate_key ../sslkey/2__.allinmd.cn.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ALL:!DH:!EXPORT:!RC4:+HIGH:+MEDIUM:-LOW:!aNULL:!eNULL; ssl_prefer_server_ciphers on;
server_name img03.allinmd.cn;
root /data/static-resource/image/img03; # error_page 404 = http://www.allinmd.cn;
location ~ \.(gif|jpg|jpeg|png|bmp|ico)$ {
expires 2d;
}
location ~ ^/WEB-INF/ {
deny all;
}
access_log /usr/local/nginx/logs/static.localhost.log access;
}
server {
listen 80;
listen 443 ssl;
ssl_certificate ../sslkey/1__.allinmd.cn_bundle.crt;
ssl_certificate_key ../sslkey/2__.allinmd.cn.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ALL:!DH:!EXPORT:!RC4:+HIGH:+MEDIUM:-LOW:!aNULL:!eNULL; ssl_prefer_server_ciphers on;
server_name img04.allinmd.cn;
root /data/static-resource/image/img04; # error_page 404 = http://www.allinmd.cn;
location ~ \.(gif|jpg|jpeg|png|bmp|ico)$ {
expires 2d;
}
location ~ ^/WEB-INF/ {
deny all;
}
access_log /usr/local/nginx/logs/static.localhost.log access;
}
server {
listen 80;
listen 443 ssl;
ssl_certificate ../sslkey/1__.allinmd.cn_bundle.crt;
ssl_certificate_key ../sslkey/2__.allinmd.cn.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ALL:!DH:!EXPORT:!RC4:+HIGH:+MEDIUM:-LOW:!aNULL:!eNULL; ssl_prefer_server_ciphers on;
server_name img99.allinmd.cn;
root /data/static-resource/image/img99; # error_page 404 = http://www.allinmd.cn;
location ~ \.(gif|jpg|jpeg|png|bmp|ico)$ {
expires 2d;
}
location ~ ^/WEB-INF/ {
deny all;
}
access_log /usr/local/nginx/logs/static.localhost.log access;
} 
server {
listen 80;
listen 443 ssl;
ssl_certificate ../sslkey/1__.allinmd.cn_bundle.crt;
ssl_certificate_key ../sslkey/2__.allinmd.cn.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ALL:!DH:!EXPORT:!RC4:+HIGH:+MEDIUM:-LOW:!aNULL:!eNULL; ssl_prefer_server_ciphers on;
server_name img98.allinmd.cn;
root /data/static-resource/image/img98; # error_page 404 = http://www.allinmd.cn;
location ~ \.(gif|jpg|jpeg|png|bmp|ico)$ {
expires 2d;
}
location ~ ^/WEB-INF/ {
deny all;
}
access_log /usr/local/nginx/logs/static.localhost.log access;
}
server {
listen 80;
listen 443 ssl;
ssl_certificate ../sslkey/1__.allinmd.cn_bundle.crt;
ssl_certificate_key ../sslkey/2__.allinmd.cn.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ALL:!DH:!EXPORT:!RC4:+HIGH:+MEDIUM:-LOW:!aNULL:!eNULL; ssl_prefer_server_ciphers on;
server_name css.allinmd.cn;
root /data/static-resource/v2/css;
error_page 404 = https://www.allinmd.cn/v2/pages/not_found.html;
location ~ \.(css)$ {
expires 2d;
}
location ~ ^/WEB-INF/ {
deny all;
}
access_log /usr/local/nginx/logs/static.localhost.log access;
}

 

posted @ 2018-12-17 17:32  fuhaizi  阅读(582)  评论(0编辑  收藏  举报