供部署nutz-book-project的童鞋参考, 部署的是https站点, http没给出,因为就是重定向到https之类的配置
server {
listen 443 ssl http2;
listen 81 ssl;
ssl_certificate /data/ssl_keys/getssl_server.crt;
ssl_certificate_key /data/ssl_keys/getssl_server.key;
server_name nutz.cn;
ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_dhparam /data/ssl_keys/dhparam.pem;
access_log /opt/nutzcn.log timed_combined;
if ( $http_host !~ "^nutz.cn") {
rewrite (.+) https://nutz.cn$1 permanent;
}
location = /google77b7f1744e22d00f.html {
root html;
}
location = /test/check_proxy {
return 444;
}
location /nutzbook {
rewrite /nutzbook/(.+) /$1;
}
location ~ "^/cgi-bin" {
return 444;
}
location ~ "^/apidocs" {
root /dev/shm/nutz-book-project;
}
location /socket.io/ {
pagespeed off;
proxy_read_timeout 60m;
proxy_set_header Host $http_host;
proxy_http_version 1.1;
proxy_set_header X-forwarded-for $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://127.0.0.1:82;
access_log off;
}
location ~ "^/druid/" {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $http_host;
proxy_set_header X-forwarded-for $remote_addr;
proxy_redirect http:// https://;
}
location /rs {
expires 8h;
root /opt/nutz-book-project/src/main/webapp;
#sendfile on;
#tcp_nopush on;
access_log off;
}
gzip_proxied no-cache no-store private expired auth;
gzip_min_length 1000;
gzip on;
gzip_comp_level 9;
gzip_vary on;
gzip_disable "msie6";
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain application/javascript image/png text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
location / {
proxy_http_version 1.1;
client_max_body_size 10m;
proxy_pass http://nutz;
proxy_set_header Host $http_host;
proxy_set_header X-forwarded-for $remote_addr;
proxy_redirect http:// https://;
#add_header Access-Control-Allow-Origin "*";
}
}
upstream nutz {
server 127.0.0.1:8080;
keepalive 65;
}
注意一下, 监听了81端口,转发到82端口了, 所以nutz-book-project里面配置需要把socketio的端口改成82