Alternate port number appended to Seafile url

I just completed setting up a new server to replace my old server. Everything is working well, excepting when I click in the Seafile client app to bring up Seafile in a web browser. My alternate port is appended to the end of the URL… Example: https://www.myseafile.com:8181/client-login/:8181

However, this behavior does not occur with my old Seafile server. Both are set up virtually identical, the only major difference being the version of NGinx I’m using.

When I copy the link from the client to the clipboard, the link is correct… Somewhere, that “:8181” is getting appended and I’m suspecting NGinx… Here is my NGinx config:

Thanks in advance.

log_format seafileformat '$http_x_forwarded_for $remote_addr [$time_local] “$request” $status $body_bytes_sent “$http_referer” “$http_user_agent” $

server {
listen 8181 ssl http2;
listen [::]:8181 ssl http2;

 ssl_certificate        /etc/ssl/certs/cert_chain.crt;
 ssl_certificate_key    /etc/ssl/certs/cert.key;

server_name www.myseafile.com;
server_tokens off;

proxy_set_header X-Forwarded-For $remote_addr;

location / {
    proxy_pass         http://127.0.0.1:8000;
    proxy_set_header   Host $host:$server_port;
    proxy_set_header   X-Real-IP $remote_addr;
    proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header   X-Forwarded-Host $server_name;
    proxy_set_header   X-Forwarded-Proto https;
    proxy_read_timeout  1200s;

    # used for view/edit office file via Office Online Server
    client_max_body_size 0;

    access_log      /var/log/nginx/seahub.access.log seafileformat;
    error_log       /var/log/nginx/seahub.error.log;
    }

location /seafhttp {
    rewrite ^/seafhttp(.*)$ $1 break;
    proxy_pass http://127.0.0.1:8082;
    client_max_body_size 0;
    proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;

    proxy_connect_timeout  36000s;
    proxy_read_timeout  36000s;
    proxy_send_timeout  36000s;
    send_timeout  36000s;

    proxy_request_buffering off;

    access_log      /var/log/nginx/seafhttp.access.log seafileformat;
    error_log       /var/log/nginx/seafhttp.error.log;
    }

location /media {
    root /opt/seafile/seafile-server-latest/seahub;
    }

# location /seafdav {
#    proxy_pass         127.0.0.1:8080;
#    proxy_set_header   Host $host;
#    proxy_set_header   X-Real-IP $remote_addr;
#    proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
#    proxy_set_header   X-Forwarded-Host $server_name;
#    proxy_set_header   X-Forwarded-Proto $scheme;
#    proxy_read_timeout 1200s;
#    client_max_body_size 0;
#
#    access_log      /var/log/nginx/seafdav.access.log;
#    error_log       /var/log/nginx/seafdav.error.log;
#
#   }

}

I’m using proxy_set_header Host $host; w/o the :$server_port part.

I changed that one a couple of years ago. With an alternate port, NGinx, SSL, and just $host w/o the $server_port, it causes csrf verification errors upon sign-in. Without SSL, it causes Seafile to often drop the port after the FQDN, and thereby a “page not found” error.

What I don’t understand is why it works perfectly on my old server. The only thing I can think is because the Nginx version I’m using now is newer and there’s an option I’m missing. I’m now on 1.18… The old server is at 1.16.