redirect - Nginx - 将 www 重定向到 https : ERR_SSL_PROTOCOL_ERROR

标签 redirect nginx https

我试图复制我其他网站的配置文件,但它不起作用,也许是因为我有一个代理?我真的不知道有什么问题。 https://mywebsite.lol没问题(由 cloudflare 提供 SSL)

server {
    server_name     www.irc.mywebsite.lol;
    rewrite ^(.*)   https://irc.mywebsite.lol$1 permanent;
}


server {
    # Port
    listen 80;

    # Hostname
    server_name irc.mywebsite.lol;

    # Logs (acces et erreurs)
    access_log /var/log/nginx/irc.mywebsite.lol.access.log;
    error_log /var/log/nginx/irc.mywebsite.lol.error.log;

     location / {
            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_pass http://localhost:7778/;
            proxy_redirect default;

            # Websocket support (from version 1.4)
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";

            pagespeed off;
    }

}

最佳答案

使用 HTTPS 端口,而不是 HTTP。它应该是

listen 443;

代替
listen 80;

关于redirect - Nginx - 将 www 重定向到 https : ERR_SSL_PROTOCOL_ERROR,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32085057/

相关文章:

php - Google 对索引重定向 URL 的 react 是什么?

python - pycurl - 302 重定向/页面移动

javascript - 通过 URL 触发 'onClick',但不访问该 URL

apache - 使用 VestaCP 在 Ubuntu 服务器上安装和配置 Varnish 缓存

java - 每个线程使用自己的代理

javascript - 输入 submit 不会执行 If/else 语句

docker - 使用 nginx 和 docker 测试本地子域

http - nginx auth_basic "Restricted"在每次请求时提示登录

非 443 端口的 SSL 证书

java - OkHttp SSL证书