'Nginx Reverts FQDN URL back to IP Address when login - NGINX Reverse Proxy

so I have a docker container running nginx as my reverse proxy to my other docker containers as follows:

  • Domain Name: 10.10.100.40 --------->> domain.com
  • Container 1: 10.10.100.40:8001 ---->> netbox.domain.com
  • Container 2: 10.10.100.40:8002 ---->> librenms.domain.com

All docker containers are within the same network called: mynetwork

In my nginx default.conf file I have the following configuration:

# Netbox Docker Proxy
server {
    listen       80;
    listen  [::]:80;
    server_name  netbox.domain.com;

    location / {
        proxy_pass http://10.10.100.40:8001;
    }

    location = /50x.html {
        root   /usr/share/nginx/html;
    }
    error_page   500 502 503 504  /50x.html;
}

# Librenms Docker Proxy
server {
    listen       80;
    listen  [::]:80;
    server_name  librenms.domain.com;

    location / {
        proxy_pass http://10.10.100.40:8002;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}

When I go to my URL and type: netbox.domain.com it works and it displays the website as expected. If I go to a subpage for example netbox.domain.com/devices/ the URL remains the same and doesn't change back to its IP address.

Problem

If I go to libremms.domain.com it works at first and it redirects me to the login page of Librenms. I type my username and password and click login and all the sudden the URL changes back to 10.10.100.40:8002/login and it sends a 419 | Page Expired.

However, if I try to access the website by using 10.10.100.40:8002 in my URL and type the Username and Password, click login and, low and behold, it let me in as normal by some reason.

I have the same nginx configuration for both dockers (Netbox and Librenms) "As seen above" and when I am in the netbox website it works flawlessly, however, librenms keeps changing the FQDN librenms.domain.com/login to --->> 10.10.100.40:8002/login everytime I try to log in, and then it fails?

Note: Even if I type only the fqdn: librenms.domain.com it redirect me automatically to librenms.domain.com/login

I am not an expert with nginx so I was hoping someone with higher experience could help me troubleshooting this problem :(

I would really appreciate it!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source