我有一个服务器,应用程序在不同的端口,我称之为微服务,主应用程序在3000并在3001中调用静态。我为https配置证书,当我配置它时,我得到错误502.我有一个文件主要的xxxxx.conf和静态的xxxx-statics.conf文件。文件是这样的。
server {
listen 80;
server_name pos.xxx.co;
return 301 https://$server_name$request_uri;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;
proxy_pass http://127.0.0.1:3000;
}
}
server {
listen 443 ssl;
server_name pos.xxx.co;
ssl_certificate /etc/nginx/ssl/xxx/ssl-bundle.crt;
ssl_certificate_key /etc/nginx/ssl/xxx/cert.xxx.co.key;
location / {
proxy_set_header HOST $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;
proxy_pass http://127.0.0.1:3000;
}
ssl on;
ssl_prefer_server_ciphers on;
}
和mi文件xxx-statics.conf
server {
listen 80;
server_name statics.xxxx.co;
return 301 https://$server_name$request_uri;
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://127.0.0.1:3001;
proxy_redirect off;
}
}
server {
listen 443 ssl;
server_name statics.xxx.co;
ssl_certificate /etc/nginx/ssl/xxxx/ssl-bundle.crt;
ssl_certificate_key /etc/nginx/ssl/xxxx/cert.xxxx.co.key;
location / {
proxy_set_header HOST $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://127.0.0.1:3001;
proxy_redirect off;
}
ssl_prefer_server_ciphers on;
}
答案 0 :(得分:0)
尝试使用" proxy_pass boxcox
$ request_uri;"
同样在http块中宣布" location /"没有必要。