# HTTPS server
server {
listen 443;
server_name ************.com;
ssl on;
ssl_certificate cert/************.com.pem;
ssl_certificate_key cert/************.com.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_prefer_server_ciphers on;
location / {
root /usr/local/web/AAAA;
index index.html index.htm;
}
root /usr/local/web;
location /BBBBB{
index index.html index.htm;
}
####重点###当在BBBB项目里后端代理路径就是以BBBB开头了,只配置/api
代理路径请求后端会报404,需要在配置/BBBBB/api的代理
location /BBBBB/api {#这里是核心,与开发环境中代理路径一定要保持一致
proxy_set_header Host $host;
proxy_set_header x-forwarded-for $remote_addr;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://************:8080/api;#后台的接口
}
####后端代理路径地址 ‘/api开头的都走这个代理’
location /api {#这里是核心,与开发环境中代理路径一定要保持一致
proxy_set_header Host $host;
proxy_set_header x-forwarded-for $remote_addr;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://************:8080;#后台的接口
}
}

这是一个关于配置HTTPS服务器并设置后端API代理的教程。配置文件中包含了SSL证书、安全协议和加密套件的设定,以及两个location块,分别处理/BBBBB/api和/api的代理请求,确保与开发环境保持一致,将请求正确转发到后台接口。

1272

被折叠的 条评论
为什么被折叠?



