關鍵點:
1、開啟ssl配置
2、proxy_set_header Host 要跟域名,如:proxy_set_header Host xxx.xxx.com;
3、如果有跨域問題,用Nginx代理,詳看:location /dsapi/部分
4、注釋部分需要替換為自己的項目信息
server {
listen 443;
server_name xxx.xxx.com; # 你的域名
ssl_certificate xxx.pem; # ssl的pem文件地址
ssl_certificate_key xxx.key; # ssl的key文件地址
#請按照以下協(xié)議配置
ssl_protocols TLSv1.2 TLSv1.3;
#請按照以下套件配置,配置加密套件,寫法遵循 openssl 標準。
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
root /www/wwwroot/xxx; # 前端項目地址
index index.html;
# 處理靜態(tài)文件請求
location / {
try_files $uri $uri/ /index.html;
}
location /dsapi/ {
rewrite ^/dsapi/(.*)$ /$1 break;
proxy_pass https://xxx.xxx.com/; # 要代理到DeepSeek的服務地址,帶協(xié)議
proxy_http_version 1.1;
proxy_set_header Host xxx.xxx.com; # 要代理到DeepSeek的服務地址,不帶協(xié)議
proxy_set_header Connection '';
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_ssl_server_name on;
proxy_ssl_verify off;
proxy_ssl_session_reuse on;
proxy_buffering off;
proxy_cache off;
proxy_request_buffering off;
chunked_transfer_encoding on;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
send_timeout 3600s;
}
}
server {
listen 80;
server_name xxx.xxx.com; # 你的域名
# 將所有 HTTP 請求重定向到 HTTPS
return 301 https://$host$request_uri;
}