Nexus的Nginx SSL终止代理不能使用不同于443的端口

yzT*_*yzT 0 reverse-proxy nginx nexus

我有一个Nginx作为Nexus存储库的SSL终止反向代理.

这是配置:

server {
    server_name nexus.example.com;
    listen 443 ssl;

    ssl_certificate /etc/letsencrypt/live/nexus.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/nexus.example.com/privkey.pem;

    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;

    client_max_body_size 1G;

    location / {
        if ($http_user_agent ~* docker) {
            proxy_pass http://127.0.0.1:8082;
        }

        proxy_pass http://127.0.0.1:8081;
        proxy_cookie_path / "/; secure; HttpOnly";

        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-Host $server_name;
        proxy_set_header   X-Forwarded-Proto $scheme;

    }

    access_log  /var/log/nginx/nexus_access.log;
    error_log /var/log/nginx/nexus_error.log;
}
Run Code Online (Sandbox Code Playgroud)

这没关系,工作正常.但是,我想在另一个端口公开Nginx,比方说10000.如果我更改配置并重新启动Nginx和Nexus,每当我访问时都会nexus.example.com:10000遇到多个错误,因为浏览器正在对资源进行请求https://nexus.example.com(没有端口) .

我认为这可能是一个缓存问题,所以我尝试了隐身模式,但它也没有用.试过一个全新的虚拟机,同样的问题,所以我放弃了缓存问题.

如果我直接在nexus.example.com:8081上公开Nexus,它也能正常工作.

可能有什么问题?

我尝试了以下解决方法,但是虽然我能够访问Nexus首页,但我无法登录.

server {
    listen 443 ssl;
    ssl_certificate /etc/letsencrypt/live/nexus.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/nexus.example.com/privkey.pem;
    location / {
        return 301 https://$host:10000$request_uri;
    }
}
Run Code Online (Sandbox Code Playgroud)

Yin*_* Yi 6

我遇到了同样的问题.改变proxy_set_header Host $host;
proxy_set_header Host $host:$server_port;解决它