rembo10 / headphones

Automatic music downloader for SABnzbd
GNU General Public License v3.0
3.37k stars 601 forks source link

Nginx redirect incorrect #2463

Open ezar opened 8 years ago

ezar commented 8 years ago

Hi, I configure nginx:

    location ~ ^/headphones($|./*) {
            proxy_pass http://127.0.0.1:8181;
            proxy_set_header X-Forwarded-Host $host;
            proxy_set_header X-Forwarded-Proto $scheme;
    }

But I use diferent port for SSL: 7777

I access to https://xxx.xxx.xxx:7777/headphones but system redirect to https://xxx.xxx.xxx/headphones and doesnt works!

Regards,

JamieMagee commented 8 years ago

Whenever you say you're listening on port 7777 for HTTPS, do you mean that nginx is listening on port 7777, or that Headphones is listening on port 7777?

Can you paste the server configuration from nginx.conf for HTTP and HTTPS?

ezar commented 8 years ago

server { listen 7777 ssl http2; server_name 192.168.1.128 localhost;

    port_in_redirect on;

    ssl_certificate /etc/nginx/cert/nginx.crt;
    ssl_certificate_key /etc/nginx/cert/nginx.key;

    ssl_session_cache shared:SSL:20m;
    ssl_session_timeout 180m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    ssl_ciphers ECDH+AESGCM:ECDH+AES256:ECDH+AES128:DH+3DES:!ADH:!AECDH:!MD5;

    add_header Strict-Transport-Security "max-age=31536000" always;

    location /sickrage {
            proxy_pass http://127.0.0.1:8081;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

    location /headphones {
            proxy_pass http://127.0.0.1:8181;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

    location /htpc {
            proxy_pass http://127.0.0.1:8085;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

    location /transmission {
            proxy_pass http://127.0.0.1:9091;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

    location /nginx_status {
            stub_status on;
            access_log   off;
    }

}

Transmission and sickrage works fine, but headphone and htpc fails. Seems a problem with this software.

ezar commented 8 years ago

Nothing?

Hellowlol commented 8 years ago

You can close this one aswell. This should work.

location /headphones { proxy_pass http://127.0.0.1:8181; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; }

xnick123 commented 8 years ago

It does work when headphones is listening on HTTP only. It doesnt if it is set to HTTPS, for me at least. Actually some pages work, others not. If e.g. i search for an artist, all is ok. If i then click on the Artist, the Port e.g. 7777 gets lost. The link is correct at the first stage: https://URL:444/hp/addArtist?artistid=79239441-bfd5-4981-a70c-55c3f15c1287

However there seems to be a redirect (not sure what) at which point the port get's lost: https://URL/hp/artistPage?ArtistID=79239441-bfd5-4981-a70c-55c3f15c1287

Has anyone else this problem?

count00zero commented 7 years ago

Hi there,

I've got the exact same problem with my nginx proxy (my https runs on a port 444 because of different portforwarding rules in my router and I need 443 forwarded to a different server). Did you find some sort of solution for that?

Thanks in advance and BR, count

azzaka commented 7 years ago

Mine does not work on http nor https. I get the following error:

404 Not Found

The path '/headphones' was not found.

Traceback (most recent call last):
  File "lib/cherrypy/_cprequest.py", line 670, in respond
    response.body = self.handler()
  File "lib/cherrypy/lib/encoding.py", line 217, in __call__
    self.body = self.oldhandler(*args, **kwargs)
  File "lib/cherrypy/_cperror.py", line 411, in __call__
    raise self
NotFound: (404, "The path '/headphones' was not found.")

Powered by CherryPy 3.6.0

Config

#####
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##

# Default server configuration
#

server {
        listen 80 default_server;
        listen [::]:80 default_server;

        #SSL configuration
        #
        listen 443 ssl default_server;
        listen [::]:443 ssl default_server;
        ssl_session_cache shared:SSL:20m;
        ssl_session_timeout 180m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

        # Self signed certs generated by the ssl-cert package
        # Don't use them in a production server!
        #
        include snippets/snakeoil.conf;

        root /var/www/html;

        # Add index.php to the list if you are using PHP
        index index.html index.htm index.php;

        server_name _;

        location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
        try_files $uri $uri/ =404;
        }

        # Location redirection for sonarr
        location /sonarr {
        proxy_pass                                      http://192.168.2.14:8989;
        proxy_set_header                                Host 192.168.2.14;
        proxy_set_header                                X-Real-IP $remote_addr;
        proxy_set_header                                X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header                                X-Forwarded-Proto $scheme;
        }

        # Location redirection for radarr
        location /radarr {
        proxy_pass                                      http://192.168.2.14:7878;
        proxy_set_header                                Host 192.168.2.14;
        proxy_set_header                                X-Real-IP $remote_addr;
        proxy_set_header                                X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header                                X-Forwarded-Proto $scheme;
        }

        # Location redirection for nzbget
        location /nzbget {
        proxy_pass                                      http://192.168.2.14:6789;
        proxy_set_header                                Host 192.168.2.14;
        proxy_set_header                                X-Real-IP $remote_addr;
        proxy_set_header                                X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header                                X-Forwarded-Proto $scheme;
        }

        # Location redirection for headphones
        location /headphones {
        proxy_pass                                      http://192.168.2.14:8181;
        proxy_set_header                                Host 192.168.2.14;
        proxy_set_header                                X-Real-IP $remote_addr;
        proxy_set_header                                X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header                                X-Forwarded-Proto $scheme;
        }
}

# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
#server {
#       listen 80;
#       listen [::]:80;
#
#       server_name example.com;
#
#       root /var/www/example.com;
#       index index.html;
#
#       location / {
#               try_files $uri $uri/ =404;
#       }
#}

Also tried setting the proxy to localhost with the same outcome. Via the port it works fine.