The weird reverse-proxy behavior of the Admin dashboard on NGINX

Issue #338 resolved
GJSMan created an issue

Hi,

I have my Poste.io image set up, and it works, though the Administration page is acting really, really weird.

For background: - I am running my email server at mail.mywebsitehere.com (not revealing real website in case of security issue) - I am doing a sort of reverse-proxy, because I want mywebsitehere.com to be a WordPress site. - So what I did was I set up Poste.io to run at mail.mywebsitehere.com, though to route all stuff from port 80 to port 82. Then, NGINX takes port 82 and routes it to the mail subdomain. - All of this works, except for the Administration page. I can go to mail.mywebsitehere.com, log in, see my mail, etc. BUT if I click on the "Administration" link, it redirects to 127.0.0.1/admin/login. I can't figure out what is going on. - I can access the admin panel, but I need to type in my server's IP address, then port 82.

Docker-compose.yml

version: '3'

services:
  mailserver:
    image: analogic/poste.io:latest
    container_name: mailserver
    restart: unless-stopped
    hostname: mail.mywebsite.com
    ports:
      - "25:25"
      - "110:110"
      - "82:80"
      - "444:443"
      - "143:143"
      - "587:587"
      - "993:993"
      - "995:995"
      - "4190:4190"
    environment:
      - VIRTUAL_HOST=mail.mywebsite.com
      - HOSTNAME=mail.mywebsite.com
      - HTTPS=OFF
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /data/nginx/html/.well-known:/opt/www/.well-known
      - /mail/data:/data

Some data from my server.ini

server_hostname = mail.srandm.com
bounce_email = postmaster@mail.srandm.com
alerts_email = admin@srandm.com
default_domain=

My NGINX config:

server {
        listen 80;
        listen [::]:80;
        root /var/www/html;

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

        server_name mail.mywebsite.com;

        location / {
                proxy_pass http://127.0.0.1:82/;
        }

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/srandm.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/srandm.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot


    if ($scheme != "https") {
        return 301 https://$host$request_uri;
    } # managed by Certbot

}

Some images below as explanatory:

badposte1.PNG badposte2.png badposte3.PNG

Note that I have manually entered the Server IP in image 3 instead of the .com address. It might work with the actual .com address, but I have nginx telling the browser to never connect to my website if there is no https connection (HSTS), so I have no idea if it would work here or not.

Critically, email delivery still works. It appears it is just the Dashboard affected with this weirdness...

Comments (3)

  1. GJSMan reporter

    What a weird weird thing... but remember how people say to clear your browser cache? I still have issues in my main browser (Chrome) and my second browser (Firefox Developer Edition), but I downloaded a new browser (Opera), tried in a Ubuntu Linux VM (Firefox), and tried on a rooted Android 4.4 tablet (Browser), and it worked just fine on all three. Weird...

    Okay, well, problem solved I guess. :)

  2. Log in to comment