nginx reverse proxy doesn't work

  • Hi,


    Im trying to fix so that I can acess my couchpotato, transmission, sickbeard, plex from and adress without ports.


    I have made a file in /etc/nginx/sites-enabled/multi_host


    Code
    server { # couchpotato
            listen [::]:80;
            proxy_redirect http://localhost/couchpotato;
    
    
            location / {
            proxy_pass http://localhost:5050;
            }
    }


    But when I restart nginx I get this error:

    Zitat

    Restarting nginx: nginx: [emerg] invalid parameter "http://localhost/couchpotato" in /etc/nginx/sites-enabled/multi_host:3
    nginx: configuration file /etc/nginx/nginx.conf test failed


    I don't understand what I am doing wrong.


    Can someone please help me out!


    Thank you!


  • But I want to access it via localhost/couchpotato
    I don't know what .lan is, and how that works?


  • lan is just a suffix in my home, it can be neglected


    I don't know how to make it work by host/servicename, and is not that simple it varies from daemon to daemon. Maybe @HK-47 can give you a hint


    Okey, but if I just write server_name couch;
    How do I access this on my browser? If I write

    Code
    [url]http://couch[/url]

    nothing happens, if I write

    Code
    [url]http://192.168.1.2/couch[/url]

    nothing happens.

  • I have LAN DHCP Server activated, and the domain name local


    And my server is at 192.168.1.2 and named nas


    If i enter nas.local I works great


    But if I enter couch.local nothing happens, not on couch.nas.local either.


    And I can only add one name to each internal IP-adress, so I can't add couch to 192.168.1.2 too


    How do I do this?


  • Okey, but if I just write server_name couch;
    How do I access this on my browser? If I write

    Code
    [url]http://couch[/url]

    nothing happens, if I write

    Code
    [url]http://192.168.1.2/couch[/url]

    nothing happens.


    I think this config should work:

    Code
    server {
        listen [::]:80;
    
    
        location /couchpotato {
            proxy_pass http://localhost:5050;
            proxy_set_header Host localhost:5050;
            proxy_redirect default;
        }
    }


    I use openwrt. I can assign multiple hostnames to the same ip. I do not know if merlin allows that. Does merlin have a ui for dnsmasq?
    Also I force the router to resolve all queries avoiding external DNS bypass.
    Is usually call DNS port 53 intercept.


    I highly recommend getting a bit more lazy. If you edit /etc/config/dhcp in OpenWRT and add something like this list address '/.nas.lan/192.168.1.10' under the dnsmasq section you have set any subdomain under nas.lan to resolv to that address. So now I just add sites with for example admin.nas.lan. No need to set up new hostnames for new sites :)

    • Offizieller Beitrag

    I highly recommend getting a bit more lazy. If you edit /etc/config/dhcp in OpenWRT and add something like this list address '/.nas.lan/192.168.1.10' under the dnsmasq section you have set any subdomain under nas.lan to resolv to that address. So now I just add sites with for example admin.nas.lan. No need to set up new hostnames for new sites


    That worked like it was always there :thumbup:



  • I think this config should work:

    Code
    server {
        listen [::]:80;
    
    
        location /couchpotato {
            proxy_pass http://localhost:5050;
            proxy_set_header Host localhost:5050;
            proxy_redirect default;
        }
    }



    I highly recommend getting a bit more lazy. If you edit /etc/config/dhcp in OpenWRT and add something like this list address '/.nas.lan/192.168.1.10' under the dnsmasq section you have set any subdomain under nas.lan to resolv to that address. So now I just add sites with for example admin.nas.lan. No need to set up new hostnames for new sites :)


    Thank you for your reply!


    I did change it to what you wrote, no errors. But I still can't access the site.
    If I go to 192.168.1.2/couchpotato I get nothing, same with nas.local/couchpotato and couchpotato.nas.local


    Do I have to change the DHCP that you wrote at the bottom too?
    Thank you!

  • Yes. You need to indicate the dhcp server who has that Hostname assigned or in the other case redirect all the prefixes for the Hostname to the ip of the nas.
    I ask again does merlin has dnsmasq configuration with extra options?


    Yes, from what I understand it does have that:
    https://github.com/RMerl/asusw…/wiki/Custom-config-files
    I can't switch from Merlin, as I use the built in DDNS service (asuscomm.com).
    But I am completely new to editing things with SSH on a router, and from what I understand you have to do the DNSMasq setup from SSH


    Can I just add this, as HK-47 said, somewhere in DNSmasq?
    list address '/.nas.local/192.168.1.2'
    (192.168.1.2 is my NAS)

  • Just so that you know - you only need to set the hostname somewhere (e.g router, /etc/hosts) if you use the server_name option.


    However, when you want to reach the site through http://ip/couch, is that the same port as OMV is running at? If that's the case, create a file in /etc/nginx/openmediavault-webgui.d/ and try this content in it:

    Code
    location /couchpotato {
        proxy_pass http://localhost:5050;
        proxy_set_header Host localhost:5050;
        proxy_redirect default;
    }


    If it doesn't work run nginx -t to test the configuration and get more detailed errors (service nginx configtest works, but doesn't give much details).

  • Just so that you know - you only need to set the hostname somewhere (e.g router, /etc/hosts) if you use the server_name option.


    However, when you want to reach the site through http://ip/couch, is that the same port as OMV is running at? If that's the case, create a file in /etc/nginx/openmediavault-webgui.d/ and try this content in it:

    Code
    location /couchpotato {
        proxy_pass http://localhost:5050;
        proxy_set_header Host localhost:5050;
        proxy_redirect default;
    }


    If it doesn't work run nginx -t to test the configuration and get more detailed errors (service nginx configtest works, but doesn't give much details).


    I don't have to reach it trough ip/couch, couch.nas.local would work if this transfers to my DDNS (asuscomm.com adress), so I can access it from couch.mydomain.asuscomm.com, if this works I don't need it to be /couch, but I don't know if I can use a "subdomain"?


    You still need to
    They're doing exactly what we do :) You still need Nginx to proxy to the correct port, unless you want to reach it through port 5050.


    I read it once more, and then i understood that it was the same thing.But I still don't understand what to add in this file in the router:/jffs/configs/hosts.add


  • I don't have to reach it trough ip/couch, couch.nas.local would work if this transfers to my DDNS (asuscomm.com adress), so I can access it from couch.mydomain.asuscomm.com, if this works I don't need it to be /couch, but I don't know if I can use a "subdomain"?


    That is possible, but only if you can enable subdomains for mydomain.asuscomm.com. The easiest way is if you can enable a "wildcard" subdomain. That way it matches any subdomain name already from Asus DNS and you won't have to mess with anything in your router. I haven't used any of their routers so sadly I'm no help.

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!