502 Bad Gateway with Nginx #7006

Closed
opened 2026-02-21 18:43:58 -05:00 by deekerman · 3 comments
Owner

Originally created by @eaglexiang on GitHub (Mar 9, 2018).

Linux version 3.10.0-693.21.1.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) ) #1 SMP Wed Mar 7 19:03:37 UTC 2018

nginx version: nginx/1.12.2

qBittorrent v3.3.7

nginx port: 80
qBtitorrent port: 8082

I want to proxy my qbit-web-ui to 80 by nginx, because of other web-service exist. But when I tried to open web-ui, it told me "502 Bad Gateway".

nginx.conf

For more information on configuration, see:

* Official English Documentation: http://nginx.org/en/docs/

* Official Russian Documentation: http://nginx.org/ru/docs/

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

Load dynamic modules. See /usr/share/nginx/README.dynamic.

include /usr/share/nginx/modules/*.conf;

events {
worker_connections 1024;
}

http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log  /var/log/nginx/access.log  main;

sendfile            on;
tcp_nopush          on;
tcp_nodelay         on;
keepalive_timeout   65;
types_hash_max_size 2048;

include             /etc/nginx/mime.types;
default_type        application/octet-stream;

# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;

server {
    listen       80 default_server;
    listen       [::]:80 default_server;
    server_name  _;
    root         /usr/share/nginx/html;

    # Load configuration files for the default server block.
    include /etc/nginx/default.d/*.conf;

    location / {
    }

    error_page 404 /404.html;
        location = /40x.html {
    }

    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }
}
server {
	listen 80;
	server_name my.qb;
	location / {
		proxy_pass http://192.168.123.10:8082;
		proxy_set_header   X-Forwarded-Host  $host:$server_port;
proxy_hide_header  Referer;
proxy_hide_header  Origin;
proxy_set_header   Referer           '';
proxy_set_header   Origin            '';
		add_header X-Frame-Options SAMEORIGIN;
	}
}

Settings for a TLS enabled server.

server {

listen 443 ssl http2 default_server;

listen [::]:443 ssl http2 default_server;

server_name _;

root /usr/share/nginx/html;

ssl_certificate "/etc/pki/nginx/server.crt";

ssl_certificate_key "/etc/pki/nginx/private/server.key";

ssl_session_cache shared:SSL:1m;

ssl_session_timeout 10m;

ssl_ciphers HIGH:!aNULL:!MD5;

ssl_prefer_server_ciphers on;

# Load configuration files for the default server block.

include /etc/nginx/default.d/*.conf;

location / {

}

error_page 404 /404.html;

location = /40x.html {

}

error_page 500 502 503 504 /50x.html;

location = /50x.html {

}

}

}

Originally created by @eaglexiang on GitHub (Mar 9, 2018). Linux version 3.10.0-693.21.1.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) ) #1 SMP Wed Mar 7 19:03:37 UTC 2018 nginx version: nginx/1.12.2 qBittorrent v3.3.7 nginx port: 80 qBtitorrent port: 8082 I want to proxy my qbit-web-ui to 80 by nginx, because of other web-service exist. But when I tried to open web-ui, it told me "502 Bad Gateway". > nginx.conf # For more information on configuration, see: # * Official English Documentation: http://nginx.org/en/docs/ # * Official Russian Documentation: http://nginx.org/ru/docs/ user nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid; # Load dynamic modules. See /usr/share/nginx/README.dynamic. include /usr/share/nginx/modules/*.conf; events { worker_connections 1024; } http { log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; # Load modular configuration files from the /etc/nginx/conf.d directory. # See http://nginx.org/en/docs/ngx_core_module.html#include # for more information. include /etc/nginx/conf.d/*.conf; server { listen 80 default_server; listen [::]:80 default_server; server_name _; root /usr/share/nginx/html; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; location / { } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } } server { listen 80; server_name my.qb; location / { proxy_pass http://192.168.123.10:8082; proxy_set_header X-Forwarded-Host $host:$server_port; proxy_hide_header Referer; proxy_hide_header Origin; proxy_set_header Referer ''; proxy_set_header Origin ''; add_header X-Frame-Options SAMEORIGIN; } } # Settings for a TLS enabled server. # # server { # listen 443 ssl http2 default_server; # listen [::]:443 ssl http2 default_server; # server_name _; # root /usr/share/nginx/html; # # ssl_certificate "/etc/pki/nginx/server.crt"; # ssl_certificate_key "/etc/pki/nginx/private/server.key"; # ssl_session_cache shared:SSL:1m; # ssl_session_timeout 10m; # ssl_ciphers HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on; # # # Load configuration files for the default server block. # include /etc/nginx/default.d/*.conf; # # location / { # } # # error_page 404 /404.html; # location = /40x.html { # } # # error_page 500 502 503 504 /50x.html; # location = /50x.html { # } # } }
Author
Owner

@1265578519 commented on GitHub (Mar 10, 2018):

为什么还要在使用一层nginx转向来增加web访问延迟。

@1265578519 commented on GitHub (Mar 10, 2018): 为什么还要在使用一层nginx转向来增加web访问延迟。
Author
Owner

@eaglexiang commented on GitHub (Mar 10, 2018):

@1265578519 因为这台机器还跑着别的web服务。我想实现的效果是访问同一个IP,nginx根据请求的域名转发对应端口的流量。以前用Apache实现过,但尝试改用nginx老是提示502

@eaglexiang commented on GitHub (Mar 10, 2018): @1265578519 因为这台机器还跑着别的web服务。我想实现的效果是访问同一个IP,nginx根据请求的域名转发对应端口的流量。以前用Apache实现过,但尝试改用nginx老是提示502
Author
Owner

@Chocobo1 commented on GitHub (Jun 2, 2018):

@eaglexiang
We only support the latest release, try upgrading qbt.
And there could be a problem in your nginx config, other users has successful results.

@Chocobo1 commented on GitHub (Jun 2, 2018): @eaglexiang We only support the latest release, try upgrading qbt. And there could be a problem in your nginx config, other users has successful results.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/qBittorrent#7006
No description provided.