当前位置:论坛首页 > Linux面板 > 求助

面板反向代理使用非443/80端口ssl无法打开网页

发表在 Linux面板2023-4-21 10:13 [复制链接] 4 2325

为了能快速了解并处理您的问题,请提供以下基础信息:
面板、插件版本:7.9.9

系统版本:Debian 11 x86_64(Py3.7.9)

问题描述:使用非443/80端口反向代理同主机安装的alist服务,一直试不成功。

相关截图(日志、错误):
我尝试了Tcping,结果是通的
使用道具 举报 只看该作者 回复
发表于 2023-4-21 10:13:51 | 显示全部楼层
使用的是Nginx1.22.1
一开始我是使用这个配置(帖子太长了,只能截图配置了):
server
{
    listen 80;
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    listen [::]:80;
    server_name alist.xxx.xxx;
    index index.php index.html index.htm default.php default.htm default.html;
    root /www/wwwroot/alist.xxx.xxx;

    #SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则
    #error_page 404/404.html;
    #HTTP_TO_HTTPS_START
    if ($server_port !~ 443){
        rewrite ^(/.*)$ https://$host$1 permanent;
    }
    #HTTP_TO_HTTPS_END
    ssl_certificate    /www/server/panel/vhost/cert/alist.xxx.xxx/fullchain.pem;
    ssl_certificate_key    /www/server/panel/vhost/cert/alist.xxx.xxx/privkey.pem;
    ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
    ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 10m;
    add_header Strict-Transport-Security "max-age=31536000";
    error_page 497  https://$host$request_uri;
    #SSL-END

    #ERROR-PAGE-START  错误页配置,可以注释、删除或修改
    #error_page 404 /404.html;
    #error_page 502 /502.html;
    #ERROR-PAGE-END

    #PHP-INFO-START  PHP引用配置,可以注释或修改
    #清理缓存规则

    location ~ /purge(/.*) {
        proxy_cache_purge cache_one $host$1$is_args$args;
        #access_log  /www/wwwlogs/alist.xxx.xxx_purge_cache.log;
    }
        #引用反向代理规则,注释后配置的反向代理将无效
        include /www/server/panel/vhost/nginx/proxy/alist.xxx.xxx/*.conf;

        include enable-php-00.conf;
    #PHP-INFO-END

    #REWRITE-START URL重写规则引用,修改后将导致面板设置的伪静态规则失效
    include /www/server/panel/vhost/rewrite/alist.xxx.xxx.conf;
    #REWRITE-END

    #禁止访问的文件或目录
    location ~ ^/(\.user.ini|\.htaccess|\.git|\.env|\.svn|\.project|LICENSE|README.md)
    {
        return 404;
    }

    #一键申请SSL证书验证目录相关设置
    location ~ \.well-known{
        allow all;
    }

    #禁止在证书验证目录放入敏感文件
    if ( $uri ~ "^/\.well-known/.*\.(php|jsp|py|js|css|lua|ts|go|zip|tar\.gz|rar|7z|sql|bak)$" ) {
        return 403;
    }

    access_log  /www/wwwlogs/alist.xxx.xxx.log;
    error_log  /www/wwwlogs/alist.xxx.xxx.error.log;
}
使用道具 举报 回复 支持 反对
发表于 2023-4-21 10:14:30 | 显示全部楼层
#PROXY-START/

location ^~ /
{
    proxy_pass http://127.0.0.1:8444;
    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 REMOTE-HOST $remote_addr;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
    proxy_http_version 1.1;
    # proxy_hide_header Upgrade;

    add_header X-Cache $upstream_cache_status;
    #Set Nginx Cache

    set $static_file2XtKstVb 0;
    if ( $uri ~* "\.(gif|png|jpg|css|js|woff|woff2)$" )
    {
        set $static_file2XtKstVb 1;
        expires 1m;
    }
    if ( $static_file2XtKstVb = 0 )
    {
        add_header Cache-Control no-cache;
    }
}
#PROXY-END/

此时内网环境直接打开alist.xxx.xxx是可以直接跳转到登录页面的。但是正如前面所说,公网环境是不行的,80/443端口被封。
alist.xxx.xxx解析的是ipv6的地址(无ipv4公网),于是我搜索了各种非80/443端口反向代理的资料之后,尝试做了如下的解决办法:

    listen 443 ssl http2;
    listen [::]:443 ssl http2;
改为了
    listen 442 ssl http2;
    listen [::]:442 ssl http2;

并且将以下这3个配置都分别试了一遍
proxy_set_header Host $hostserver_port;
proxy_set_header Host $http_host;
proxy_set_header Host $host:442;
此时仍然不能通过https://alist.xxx.xxx:442/访问,打开这个网址将会直接变成https://alist.xxx.xxx/,端口号直接丢失,即使是使用edge浏览器的无痕模式也不行,我亦尝试了Safari浏览器,依然不行。

此时我再将  强制HTTPS  关闭的话,虽然内网主机的edge浏览器在无痕模式下能够打开了,但是其他非内网设备、非无痕模式浏览器依然无法打开,比如我的手机依然打不开。
使用道具 举报 回复 支持 反对
发表于 2023-4-21 10:15:06 | 显示全部楼层
在部署面板的主机上尝试运行了命令:curl -v alist.xxx.xxx:442,结果如下:
*   Trying 2409:xxxxxxxxxxxxxxxxx
* Connected to alist.xxx.xxx (2409:xxxxxxxxxxxxxxxxx) port 442 (#0)
> GET / HTTP/1.1
> Host: alist.xxx.xxx:442
> User-Agent: curl/7.74.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 302 Moved Temporarily
< Server: nginx
< Date: Fri, 21 Apr 2023 01:32:37 GMT
< Content-Type: text/html
< Content-Length: 138
< Connection: close
< Location: https://alist.xxx.xxx/
< Strict-Transport-Security: max-age=31536000
<
<html>
<head><title>302 Found</title></head>
<body>
<center><h1>302 Found</h1></center>
<hr><center>nginx</center>
</body>
</html>
* Closing connection 0
使用道具 举报 回复 支持 反对
发表于 2023-10-25 17:36:43 | 显示全部楼层
白纸 发表于 2023-4-21 10:15
在部署面板的主机上尝试运行了命令:curl -v alist.xxx.xxx:442,结果如下:
*   Trying 2409:xxxxxxxxxxxx ...

您好,您强制https那里的443 有没有修改成442?
使用道具 举报 回复 支持 反对
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

企业版年付运维跟进群

普通问题处理

论坛响应时间:72小时

问题处理方式:排队(仅解答)

工作时间:白班:9:00 - 18:00

紧急问题处理

论坛响应时间:10分钟

问题处理方式:1对1处理(优先)

工作时间:白班:9:00 - 18:00

工作时间:晚班:18:00 - 24:00

立即付费处理
快速回复 返回顶部 返回列表