nginx conf 简单配置

nginx conf 配置

upstream t****.com {
server localhost:9041;
}

server {
listen 80;
server_name t****.com;#域名
return 301 https://$server_name$request_uri;
}

server {
listen 443 ssl;
server_name t****.com; #域名

# 增加ssl
ssl on; #如果强制HTTPs访问,这行要打开
ssl_certificate /home/nginx/ssl/1_t****.com_bundle.crt;
ssl_certificate_key /home/nginx/ssl/2_t****.com.key;

ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;

# 指定密码为openssl支持的格式
ssl_protocols SSLv2 SSLv3 TLSv1.2;

ssl_ciphers HIGH:!aNULL:!MD5; # 密码加密方式
ssl_prefer_server_ciphers on; # 依赖SSLv3和TLSv1协议的服务器密码将优先于客户端密码

# 定义首页索引目录和名称
location ^~ / {
root /home/web/teacher-web/dist;
index index.html;
try_files $uri $uri/ /index.html;
}

location ^~ /api/ {
proxy_pass http://t****.com;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Remote_addr $remote_addr;

rewrite "^/api/(.*)$" /$1 break;
}

#重定向错误页面到 /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}


}

posted @ 2022-10-08 16:27  深水是沉默  阅读(117)  评论(0编辑  收藏  举报