This commit is contained in:
deepzz0
2016-10-02 00:11:15 +08:00
parent ddf508825c
commit ead9533be3
34 changed files with 359 additions and 181 deletions

View File

@@ -4,24 +4,25 @@ server {
server_name www.deepzz.com deepzz.com;
server_tokens off;
include /data/eiblog/nginx/ip.blacklist;
include /data/eiblog/conf/nginx/ip.blacklist;
# 现在一般证书是内置的。可以注释该项
# https://imququ.com/post/certificate-transparency.html#toc-2
# ssl_ct on;
# ssl_ct_static_scts /home/jerry/www/scts;
# ssl_ct_static_scts /data/eiblog/conf/scts;
# 中间证书 + 站点证书
ssl_certificate /data/eiblog/conf/certs/chained.pem;
ssl_certificate /data/eiblog/conf/ssl/domain.pem;
# 创建 CSR 文件时用的密钥
ssl_certificate_key /data/eiblog/conf/certs/domain.key;
ssl_certificate_key /data/eiblog/conf/ssl/domain.key;
# openssl dhparam -out dhparams.pem 2048
# https://weakdh.org/sysadmin.html
ssl_dhparam /data/eiblog/conf/ssl/dhparams.pem;
# https://github.com/cloudflare/sslconfig/blob/master/conf
ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
# 如果启用了 RSA + ECDSA 双证书Cipher Suite 可以参考以下配置:
# ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+ECDSA+AES128:EECDH+aRSA+AES128:RSA+AES128:EECDH+ECDSA+AES256:EECDH+aRSA+AES256:RSA+AES256:EECDH+ECDSA+3DES:EECDH+aRSA+3DES:RSA+3DES:!MD5;
@@ -37,19 +38,19 @@ server {
# openssl rand 48 > session_ticket.key
# 单机部署可以不指定 ssl_session_ticket_key
ssl_session_ticket_key /data/eiblog/conf/ssl/session_ticket.key;
# ssl_session_ticket_key /data/eiblog/conf/ssl/session_ticket.key;
ssl_stapling on;
ssl_stapling_verify on;
# 根证书 + 中间证书
# https://imququ.com/post/why-can-not-turn-on-ocsp-stapling.html
# ssl_trusted_certificate /home/jerry/www/ssl/full_chained.pem;
# ssl_trusted_certificate /data/eiblog/conf/ssl/full_chained.pem;
resolver 114.114.114.114 valid=300s;
resolver_timeout 10s;
access_log /data/eiblog/log/nginx.log;
access_log /data/eiblog/logdata/nginx.log;
if ($request_method !~ ^(GET|HEAD|POST|OPTIONS)$ ) {
return 444;
@@ -59,8 +60,9 @@ server {
rewrite ^/(.*)$ https://deepzz.com/$1 permanent;
}
# webmaster 站点验证相关
location ~* (robots\.txt|favicon\.ico|crossdomain\.xml|google4c90d18e696bdcf8\.html|BingSiteAuth\.xml)$ {
root /home/jerry/www/imququ.com/www/static;
root /data/eiblog/static;
expires 1d;
}
@@ -80,7 +82,7 @@ server {
}
location ^~ /static/ {
root /home/jerry/www/imququ.com/www;
root /data/eiblog;
add_header Access-Control-Allow-Origin *;
expires max;
}
@@ -96,13 +98,14 @@ server {
add_header X-Content-Type-Options nosniff;
proxy_set_header X-Via QingDao.Aliyun;
# proxy_set_header X-Via QingDao.Aliyun;
proxy_set_header Connection "";
proxy_set_header Host imququ.com;
proxy_set_header Host deepzz.com;
proxy_set_header X-Real_IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-XSS-Protection 1; mode=block;
proxy_pass http://127.0.0.1:9095;
proxy_pass http://127.0.0.1:9000;
}
location / {
@@ -111,8 +114,11 @@ server {
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload";
add_header X-Frame-Options deny;
add_header X-Content-Type-Options nosniff;
add_header Content-Security-Policy "default-src 'none'; script-src 'unsafe-inline' 'unsafe-eval' blob: https:; img-src data: https: http://ip.qgy18.com; style-src 'unsafe-inline' https:; child-src https:; connect-src 'self' https://translate.googleapis.com; frame-src https://disqus.com https://www.slideshare.net";
add_header Public-Key-Pins 'pin-sha256="YLh1dUR9y6Kja30RrAn7JKnbQG/uEtLMkBgFF2Fuihg="; pin-sha256="aef6IF2UF6jNEwA2pNmP7kpgT6NFSdt7Tqf5HzaIGWI="; max-age=2592000; includeSubDomains';
# 改deepzz相关的
add_header Content-Security-Policy "default-src 'none'; script-src 'unsafe-inline' 'unsafe-eval' blob: https:; img-src data: https: https://st.deepzz.com; style-src 'unsafe-inline' https:; child-src https:; connect-src 'self' https://translate.googleapis.com; frame-src https://disqus.com https://www.slideshare.net";
# 中间证书证书指纹
# https://imququ.com/post/http-public-key-pinning.html
add_header Public-Key-Pins 'pin-sha256="JbQbUG5JMJUoI6brnx0x3vZF6jilxsapbXGVfjhN8Fg="; pin-sha256="YLh1dUR9y6Kja30RrAn7JKnbQG/uEtLMkBgFF2Fuihg="; max-age=2592000; includeSubDomains';
add_header Cache-Control no-cache;
proxy_ignore_headers Set-Cookie;
@@ -120,13 +126,13 @@ server {
proxy_hide_header Vary;
proxy_hide_header X-Powered-By;
proxy_set_header X-Via QingDao.Aliyun;
# proxy_set_header X-Via QingDao.Aliyun;
proxy_set_header Connection "";
proxy_set_header Host deepzz.com;
proxy_set_header X-Real_IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:9095;
proxy_pass http://127.0.0.1:9000;
}
}
@@ -148,4 +154,29 @@ server {
location / {
rewrite ^/(.*)$ https://deepzz.com/$1 permanent;
}
}
# 原博客,内部做的转发
server {
server_name blog.deepzz.com;
access_log /dev/null;
location / {
rewrite ^/(.*)$ https://blog.deepzz.com/$1 permanent;
}
}
server {
listen 443;
server_name blog.deepzz.com;
add_header Strict-Transport-Security "max-age=31536000";
add_header X-Frame-Options deny;
add_header X-Content-Type-Options nosniff;
add_header X-Xss-Protection "1; mode=block;";
location / {
proxy_pass https://127.0.0.1:9010;
}
}

0
conf/nginx/ip.blacklist Normal file
View File

View File

@@ -1,95 +1,131 @@
user www-data;
worker_processes 4;
pid /run/nginx.pid;
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
charset UTF-8;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
##
# Basic Settings
##
#access_log logs/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
#keepalive_timeout 0;
keepalive_timeout 65;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
gzip on;
gzip_vary on;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip_comp_level 6;
gzip_buffers 16 8k;
##
# Gzip Settings
##
gzip_min_length 1000;
gzip_proxied any;
gzip_disable "msie6";
gzip on;
gzip_disable "msie6";
gzip_http_version 1.0;
gzip_min_length 1000;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript image/svg+xml;
##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript image/svg+xml;
#include /etc/nginx/naxsi_core.rules;
server {
listen 80;
server_name localhost;
##
# nginx-passenger config
##
# Uncomment it if you installed nginx-passenger
##
#charset koi8-r;
#passenger_root /usr;
#passenger_ruby /usr/bin/ruby;
#access_log logs/host.access.log main;
##
# Virtual Host Configs
##
location / {
root html;
index index.html index.htm;
}
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
#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;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# 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;
# }
#}
include /data/eiblog/conf/nginx/domain/*.conf;
}
#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}