nginx版本:nginx/1.16.1
需要注意两点
1 有的版本 443server要在80前面
2 有的端口监听需要加ssl
listen 443 ssl;
listen 443;
CenterOS 服务器拷贝下来的示例:
user root root;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
server {
listen 443 ssl;
server_name www.elgratia.com elgratia.com;
root /root/kb/feedback/web;
#access_log logs/nginx.access.log main;
ssl_certificate /root/https/www.elgratia.com_chain.crt;
ssl_certificate_key /root/https/www.elgratia.com_key.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
location / {
root /root/kb/feedback/web;
index index.html;
}
location ^~ /api{
proxy_pass http://156.232.6.221:3900/api;
}
}
server {
listen 80;
server_name www.elgratia.com elgratia.com;
index index.html index.htm;
root /root/kb/feedback/web;
client_max_body_size 15M;
location / {
#root /root/kb/feedback/web;
#proxy_pass http://156.232.6.221:80;
index index.html index.htm;
try_files $uri $uri/ @router;
}
location ^~ /api {
proxy_pass http://156.232.6.221:3900/api;
}
location @router {
rewrite ^.*$ /index.html last;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
#gzip on;
#include /etc/nginx/vhosts/*;
# include /etc/nginx/conf.d/*.conf;
}