ssl - 反向代理时如何阻止Nginx向外部url添加端口

标签 ssl nginx cdn cloudinary

我在服务 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/

相关文章:

jQuery 托管在 Google CDN : why is Internet access still needed?

javascript - https ://code. angularjs.org 上的 Angular-2-Release 在哪里?

android - 证书签发: SSL page brings up "you need to set a lock screen pin or password before you can use credential storage" on Android

apache - SSL 错误 Zend Framework BoxAPI

php - 在使用相互/双向身份验证(使用 p12 证书)访问页面时提示每个 session 输入密码

php - Directadmin + Nginx + php fpm + 位置 : File not found

javascript - 可以同时使用 Dojo.Build 和 CDN 吗?

SSL 证书 webmin

php - Laravel 路由在实时服务器上导致 404 错误

django - 如何让 Gunicorn 使用 Python 3 而不是 Python 2(502 Bad Gateway)