时间:2021-10-21 作者:冰城心无泪 分类: Linux应用
user root;
worker_processes 2;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
server_tokens off;
sendfile on;
gzip on;
keepalive_timeout 65;
client_max_body_size 2048m;
server {
listen 80;
server_name www.domain_name.com;
if ($host != 'www.domain_name.com'){
return 444;
}
location / {
root /usr/share/nginx/html;
index index.html index.htm index.php;
}
}
user root;
worker_processes 2;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
server_tokens off;
sendfile on;
gzip on;
keepalive_timeout 65;
client_max_body_size 2048m;
server {
listen 80;
server_name www.domain_name.com;
rewrite ^(.*)$ https://$host$1 permanent;
location / {
root /html;
index index.html index.htm index.php;
}
server {
listen 443 ssl http2;
server_name www.domain_name.com;
if ($host != 'www.domain_name.com'){
return 444;
}
charset utf-8;
#证书的目录及文件名称根据实际修改
ssl_certificate /Nginx/ssl/www.domain_name.com_chain.crt;
ssl_certificate_key /Nginx/ssl/www.domain_name.com_key.key;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 5m;
#如果你是使用Openss 1.1.1*版本编译的Nginx,SSL协议可以支持TLSv1.3.
ssl_protocols TLSv1.1 TLSv1.2;
ssl_ciphers ECDH:AESGCM:HIGH:!RC4:!DH:!MD5:!3DES:!aNULL:!eNULL;
#如果你ssl协议只开启支持tlsv1.2 tlsv1.3新协议,建议使用以下加密套件
#ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
#如果ssl协议只支持tlsv1.2 tlsv1.3新协议,设置为 off,如果ssl协议支持tlsv1 tls1.1这种老协议,设置为 on,默认为off,因为新协议不再采纳此参数
ssl_prefer_server_ciphers on;
add_header Strict-Transport-Security "max-age=63072000" always;
location / {
root html;
index index.html index.htm;
try_files $uri $uri/ @router;
}
}
}
user root;
worker_processes 2;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
server_tokens off;
sendfile on;
gzip on;
keepalive_timeout 65;
client_max_body_size 2048m;
#下面这段server是新加的
server {
listen 80 default_server;
server_name _;
return 444;
}
server {
listen 80;
server_name www.domain_name.com domain_name.com;
location / {
root /usr/share/nginx/html;
index index.html index.htm index.php;
}
}
user root;
worker_processes 2;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
server_tokens off;
sendfile on;
gzip on;
keepalive_timeout 65;
client_max_body_size 2048m;
#下面这段server是新加的
server {
listen 80 default_server;
listen 443 ssl default_server;
server_name _;
return 444;
#证书的目录及文件名称根据实际修改
ssl_certificate /Nginx/ssl/www.domain_name.com_chain.crt;
ssl_certificate_key /Nginx/ssl/www.domain_name.com_key.key;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 5m;
#如果你是使用Openss 1.1.1*版本编译的Nginx,SSL协议可以支持TLSv1.3.
ssl_protocols TLSv1.1 TLSv1.2;
ssl_ciphers ECDH:AESGCM:HIGH:!RC4:!DH:!MD5:!3DES:!aNULL:!eNULL;
#如果你ssl协议只开启支持tlsv1.2 tlsv1.3新协议,建议使用以下加密套件
#ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
#如果ssl协议只支持tlsv1.2 tlsv1.3新协议,设置为 off,如果ssl协议支持tlsv1 tls1.1这种老协议,设置为 on,默认为off,因为新协议不再采纳此参数
ssl_prefer_server_ciphers on;
}
server {
listen 80;
#多个域名用空格隔开。
server_name www.domain_name.com domain_name.com;
rewrite ^(.*)$ https://$host$1 permanent;
location / {
root /html;
index index.html index.htm index.php;
}
server {
listen 443 ssl http2;
#多个域名用空格隔开。
server_name www.domain_name.com domain_name.com;
charset utf-8;
#证书的目录及文件名称根据实际修改
ssl_certificate /Nginx/ssl/www.domain_name.com_chain.crt;
ssl_certificate_key /Nginx/ssl/www.domain_name.com_key.key;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 5m;
ssl_protocols TLSv1.1 TLSv1.2;
ssl_ciphers ECDH:AESGCM:HIGH:!RC4:!DH:!MD5:!3DES:!aNULL:!eNULL;
#如果你ssl协议只开启支持tlsv1.2 tlsv1.3新协议,建议使用以下加密套件
#ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
#如果ssl协议只支持tlsv1.2 tlsv1.3新协议,设置为 off,如果ssl协议支持tlsv1 tls1.1这种老协议,设置为 on,默认为off,因为新协议不再采纳此参数
ssl_prefer_server_ciphers on;
location / {
root html;
index index.html index.htm;
try_files $uri $uri/ @router;
}
}
}