关键点:
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文件地址
#请按照以下协议配置
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;
# 处理静态文件请求
location / {
try_files $uri $uri/ /index.html;
}
location /dsapi/ {
rewrite ^/dsapi/(.*)$ /$1 break;
proxy_pass https://xxx.xxx.com/; # 要代理到DeepSeek的服务地址,带协议
proxy_http_version 1.1;
proxy_set_header Host xxx.xxx.com; # 要代理到DeepSeek的服务地址,不带协议
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;
}