我在尝试在 Nginx 中为本地主机中的应用 运行 配置反向代理时遇到问题
I'm facing issues trying to configure reverse proxy in Nginx, for an app running in localhost
我已经 Pterodactyl 在 Digital Ocean droplet 运行 Ubuntu v18.04.4 LTS 上设置。大约一年前,我将它与 Nginx 一起设置,设置了 A 记录 (panel.example.com),并且它与 Let's Encrypt SSL 证书配合得非常好。
几天前,我决定设置 The Lounge, a self hosted Web IRC client. By default it runs on port 9000. I followed their recommended instructions,更改人们在他们的帮助 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
。但出于某种原因,使用下面的配置,它开始重定向到 "you've set up nginx correctly" 页面。现在,几天后,我被引导到 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;
}
}
休息室绑定到我的 public IP。将配置更改为指向 serverip:port 而不是 localhost 并且有效。
我已经 Pterodactyl 在 Digital Ocean droplet 运行 Ubuntu v18.04.4 LTS 上设置。大约一年前,我将它与 Nginx 一起设置,设置了 A 记录 (panel.example.com),并且它与 Let's Encrypt SSL 证书配合得非常好。
几天前,我决定设置 The Lounge, a self hosted Web IRC client. By default it runs on port 9000. I followed their recommended instructions,更改人们在他们的帮助 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
。但出于某种原因,使用下面的配置,它开始重定向到 "you've set up nginx correctly" 页面。现在,几天后,我被引导到 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;
}
}
休息室绑定到我的 public IP。将配置更改为指向 serverip:port 而不是 localhost 并且有效。