nginx 配置
· One min read
nginx 配置。
基本配置
server {
server_name test.henmao.com;
index index.html index.htm;
access_log /var/log/nginx/test_access.log;
error_log /var/log/nginx/test_error.log;
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect off;
# 线上内网地址
proxy_pass http://10.0.12.5:9502;
autoindex_localtime on;
}
}
HTTPS 配置
# 配置 ssl 相关内容
server {
# ... 基本配置
listen 443 ssl; # managed by Certbot
ssl_certificate /ssl/live/henmao.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /ssl/live/henmao.com/privkey.pem; # managed by Certbot
}
server {
if ($host = test.henmao.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
server_name test.henmao.com;
listen 80;
return 404; # managed by Certbot
}