我在服务 Cloudinary url 时遇到了 Nginx 的问题。
我已经设置了一个反向代理,它基本上为我的本地主机应用程序提供公共(public)服务,并强制使用 https。
我正在使用 Cloudinary 作为我的图像服务。
问题是出于某种原因,Nginx 将 :80 添加到我的 Cloudinary url 的主机部分,这会导致 404 错误。
例如,我所有的网址都变成了 https://res.cloudinary.com:80/ ...
这是我的反向代理配置:
server {
listen 80;
server_name test.example.com;
return 301 https://$host$request_uri;
}
server {
listen 443;
server_name test.example.com;
ssl on;
ssl_certificate /etc/nginx/ssl/*.example.com/server.crt;
ssl_certificate_key /etc/nginx/ssl/*.example.com/server.key;
location / {
proxy_pass http://localhost:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
我做错了什么?
最佳答案
查看您的 nginx
配置,它会将 /
下的所有请求代理到 http://localhost:8080
。我无法从上面的配置片段中看到它会代理到 https://res.cloudinary.com:80/ .
如果我不得不猜测,是在您的本地主机上运行的 8080 端口上的应用程序/服务对此负责。您检查过是否是这种情况吗?
关于ssl - 反向代理时如何阻止Nginx向外部url添加端口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53732439/