我在Nginx中为一个运行在localhost的应用程序配置反向代理时遇到了问题。

问题描述 投票:0回答:0

我已经得到了 翼龙 在运行Ubuntu v18.04.4 LTS的Digital Ocean液滴上设置。大约一年前,我把它和Nginx一起设置,设置了A记录(panel.example.com),并且在使用Let's Encrypt SSL证书的情况下工作得很好。

几天前,我决定在Nginx上设置 休息室,是一个自我托管的Web IRC客户端。默认情况下,它运行在9000端口。 我按照他们的建议 说明,改变了他们帮助IRC频道上的人推荐的一些东西。与翼龙面板不同的是,我希望这个显示在我的个人域名上。所以,我设置了我的A记录指向我的DO droplet,主机值为 irc因此,它将显示在 irc.yash.gg. 然后,我使用acme.sh在独立模式下生成Let's Encrypt密钥。然后,我将下面的配置添加到 /etc/nginx/sites-available/thelounge.conf,并将其链接到 /etc/nginx/sites-enabled/thelounge.conf. 但不知道为什么,用下面的配置,它开始重定向到 "你已经正确设置了nginx "页面。而现在,几天后,我被引导到我的翼龙面板,而不是panel.sneakycraft.com。

我完全迷茫了,我不明白这是怎么回事。我真的很感激一些帮助。请让我知道,如果我可以提供任何其他帮助诊断这个问题。

谢谢!我有一个翼龙。

server {
    listen 80;
    listen [::]:80;
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name irc.yash.gg;

    ssl_stapling on;
    ssl_stapling_verify on;
    resolver 1.1.1.1 1.0.0.1 [2606:4700:4700::1111] [2606:4700:4700::1001] valid=300s;
    resolver_timeout 5s;

    charset utf-8;

    location ^~ /irc/ {
    proxy_pass https://127.0.0.1:9000/;
    proxy_ssl_protocols TLSv1.2 TLSv1.3;
    proxy_set_header Connection "upgrade";
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_set_header X-Forwarded-Proto $scheme;

    # by default nginx times out connections in one minute
    proxy_read_timeout 1d;
#    proxy_redirect      http://127.0.0.1:9000 https://irc.yash.gg;
}

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log /var/log/nginx/thelounge.app-access.log;
    error_log  /var/log/nginx/thelounge.app-error.log error;

    # allow larger file uploads and longer script runtimes
    client_max_body_size 100m;
    client_body_timeout 120s;

    sendfile off;

    # SSL Configuration
    ssl_certificate /etc/letsencrypt/live/irc.yash.gg/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/irc.yash.gg/privkey.pem;
    ssl_session_cache shared:SSL:10m;
    ssl_trusted_certificate /etc/letsencrypt/live/irc.yash.gg/fullchain.pem;

    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256';
    ssl_prefer_server_ciphers on;

    ssl_dhparam /etc/ssl/certs/dhparam.pem;
    ssl_ecdh_curve secp384r1; # Requires nginx >= 1.1.0

    # See https://hstspreload.org/ before uncommenting the line below.
    # add_header Strict-Transport-Security "max-age=15768000; preload;";
    add_header X-Content-Type-Options nosniff;
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Robots-Tag none;
    add_header Content-Security-Policy "frame-ancestors 'self'";
    add_header X-Frame-Options DENY;
    add_header Referrer-Policy same-origin;

#    location ~ \.php$ {
#        fastcgi_split_path_info ^(.+\.php)(/.+)$;
#        fastcgi_pass unix:/run/php/php7.2-fpm.sock;
#        fastcgi_index index.php;
#        include fastcgi_params;
#        fastcgi_param PHP_VALUE "upload_max_filesize = 100M \n post_max_size=100M";
#        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#        fastcgi_param HTTP_PROXY "";
#        fastcgi_intercept_errors off;
#        fastcgi_buffer_size 16k;
#        fastcgi_buffers 4 16k;
#        fastcgi_connect_timeout 300;
#        fastcgi_send_timeout 300;
#        fastcgi_read_timeout 300;
#    }

    location ~ /\.ht {
        deny all;
    }
}
nginx reverse-proxy nginx-reverse-proxy
© www.soinside.com 2019 - 2024. All rights reserved.