server {
listen 443 ssl; #SSL协议访问端口号为443。此处如未添加ssl,可能会造成Nginx无法启动。
server_name api.snailslife.cn;
index index.html index.htm;
ssl_certificate /usr/local/nginx/cert/api_snailslife/api.snailslife.cn_bundle.crt; #将domain name.pem替换成您证书的文件名。
ssl_certificate_key /usr/local/nginx/cert/api_snailslife/api.snailslife.cn.key; #将domain name.key替换成您证书的密钥文件名。
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; #使用此加密套件。
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #使用该协议进行配置。
ssl_prefer_server_ciphers on;
access_log /home/logs/api_access.log access;
proxy_intercept_errors on;
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location / {
proxy_pass http://127.0.0.1:8213;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
}
}
/usr/local/nginx/conf/all/api_snailslife_cn.conf
#user nobody;
worker_processes auto;
error_log /usr/local/nginx/logs/error.log crit;
pid logs/nginx.pid;
worker_rlimit_nofile 65535;
events
{
use epoll;
worker_connections 65535;
multi_accept on;
}
http {
include mime.types;
default_type application/octet-stream;
charset utf-8;
keepalive_timeout 60;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 10m;
client_body_buffer_size 64k;
open_file_cache max=102400 inactive=20s;
open_file_cache_min_uses 2;
open_file_cache_valid 60s;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml;
gzip_vary on;
gzip_disable "MSIE [1-6]\.";
gzip_proxied expired no-cache no-store private auth;
proxy_redirect off;
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_connect_timeout 60;
proxy_read_timeout 120;
proxy_send_timeout 120;
log_format access '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $http_x_forwarded_for';
#集群配置文件
include /usr/local/nginx/conf/all/api_snailslife_cn.conf;
}