How to set the non-stand port on SWAG proxy for calibre-web?

My scenario is I used SWAG as proxy for calibre-web.
my website port is nonstandard, that means I don’t use 80, or 443 as web server site port.
I used subdomain method for the proxy setting. the configuration file in file “calibre-web.subdomain.conf” look like below:
----------------------------------------------calibre-web.subdomain.conf

Version 2020/12/09

make sure that your dns has a cname set for calibre-web

server {
listen 443 ssl;
listen [::]:443 ssl;

server_name calibre-web.*;

include /config/nginx/ssl.conf;

client_max_body_size 0;

# enable for ldap auth, fill in ldap details in ldap.conf
#include /config/nginx/ldap.conf;

# enable for Authelia
#include /config/nginx/authelia-server.conf;

location / {
    # enable the next two lines for http auth
    #auth_basic "Restricted";
    #auth_basic_user_file /config/nginx/.htpasswd;

    # enable the next two lines for ldap auth, also customize and enable ldap.conf in the default conf
    #auth_request /auth;
    #error_page 401 =200 /ldaplogin;

    # enable for Authelia
    #include /config/nginx/authelia-location.conf;

    include /config/nginx/proxy.conf;
    resolver 127.0.0.11 valid=30s;
    set $upstream_app calibre-web;
    set $upstream_port 8083;
    set $upstream_proto http;
	#proxy_bind $server_addr;
	proxy_bind $remote_addr;
    proxy_pass $upstream_proto://$upstream_app:$upstream_port;

    proxy_set_header X-Scheme $scheme;
	#proxy_redirect http://$host/ https://$host:5000/;
}

}
---------------------------------------------end of the file.

everything is OK, but just when I click login, the content link jumped to calibre-web.xx.duckdns.org, not calibre-web.xx.duckdns.org:5000 again, then the browser report error because it can not access the server from standard port.

so does anybody could help to give me some advise, to make the link jumped but still with initial defined port(like 5000). thanks!

If you don’t want to use 443 as a https port, why are you making nginx listen on 443?

server {
listen 443 ssl;
listen [::]:443 ssl;
1 Like

I solved the issue finally by modified the subdomain file. hope it could help somebody with same kind of scenario.


#Version 2021/05/18
/#make sure that your dns has a cname set for calibre-web

server {
    listen 443 ssl;
    listen [::]:443 ssl;

    server_name calibre-web.*;

    include /config/nginx/ssl.conf;

    client_max_body_size 0; 

    # enable for ldap auth, fill in ldap details in ldap.conf
    #include /config/nginx/ldap.conf;

    # enable for Authelia
    #include /config/nginx/authelia-server.conf;

    location / {
        # enable the next two lines for http auth
        #auth_basic "Restricted";
        #auth_basic_user_file /config/nginx/.htpasswd;

        # enable the next two lines for ldap auth, also customize and enable ldap.conf in the default conf
        #auth_request /auth;
        #error_page 401 =200 /ldaplogin;

        # enable for Authelia
        #include /config/nginx/authelia-location.conf;

        include /config/nginx/proxy.conf;
        include /config/nginx/resolver.conf;
        set $upstream_app calibre-web;
        set $upstream_port 8083;
        set $upstream_proto http;
        proxy_pass $upstream_proto://$upstream_app:$upstream_port;

        #proxy_set_header X-Scheme $scheme;
        proxy_set_header        Host            $http_host;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header        X-Scheme        $scheme;
        proxy_set_header        X-Script-Name   /calibre-web;
       
	proxy_redirect https://$host/ https://$host:4xxx/;**#The port is your self defined port, added this port it could solve issue of redirection.
    }
}

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.