liu 11 ماه پیش
والد
کامیت
2c0d0ed4f9
1فایلهای تغییر یافته به همراه15 افزوده شده و 7 حذف شده
  1. 15 7
      nginx-1.26.3/conf/nginx.conf

+ 15 - 7
nginx-1.26.3/conf/nginx.conf

@@ -150,16 +150,24 @@ http {
     # another virtual host using mix of IP-, name-, and port-based configuration
     #
     server {
-        listen       80 ssl;
-        server_name  api.ygtxfj.com;
+        # 标准HTTPS监听端口
+        listen 443 ssl;
+        server_name api.ygtxfj.com;
 
-        # 证书路径
-        ssl_certificate scs1739178580156_api.ygtxfj.com_server.crt;  # 证书文件(含完整链)
-        ssl_certificate_key scs1739178580156_api.ygtxfj.com_server.key; 
+        # SSL证书配置(建议使用绝对路径
+        ssl_certificate /etc/nginx/ssl/scs1739178580156_api.ygtxfj.com_server.crt;
+        ssl_certificate_key /etc/nginx/ssl/scs1739178580156_api.ygtxfj.com_server.key;
 
-        location /fLxiFxSceH.txt {
+        # HTTP强制跳转HTTPS(可选)
+        listen 80;
+        return 301 https://$host$request_uri;
+
+        location = /fLxiFxSceH.txt {
             proxy_pass http://localhost:8080/static/fLxiFxSceH.txt;
-            expires 30d; # 缓存优化
+            expires 30d;
+            # 推荐增加的代理头信息
+            proxy_set_header Host $host;
+            proxy_set_header X-Real-IP $remote_addr;
         }
     }