NGINX:如何从URL删除端口?

问题描述

我在端口8929上有服务,然后像这样设置反向代理


server {
    server_name xxxx.com;

    location / {
        proxy_pass         http://xxxx.com:8929;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Host $http_host;
    }


    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/xxxx.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/xxxx.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}
server {
    if ($host = xxxx.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    listen 80;
    server_name xxxx.com;
    return 404; # managed by Certbot

    location / {
      proxy_redirect https://$host:8929$request_uri https://$host$request_uri;
   }
}

昨天,当我不使用certbot时,一切都正常进行,当我使用xxxx.com:8929访问url时,它可以正常运行,但是当我使用certbot并且访问xxxx.com:8929时已经安装了SSL时,就会收到错误消息像下面的

此网站无法提供安全的连接xxxx.com发送了无效的回复。 ERR_SSL_PROTOCOL_ERROR

我想怎么做,以便当用户访问https://xxxx.com:8929时他将重定向到https:// $ host $ request_uri?

这有可能吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...