Node Server leads to 502: Bad Gateway

So I tried installing “Wiki.JS” on my instance and tie it to HestiaCP. However, after I finally managed to get stuff working at least with the IP:Port which I can access it that way, when I try to modify my default.stpl/.tpl to tie it to the Port of the Node Server so I can access it through the URL instead, it simply leads to:


When I run the command “node server” in the “wiki” directory that I created from said guide, I can access it on the IP:3001 (port) like I said, just not the URL even though I changed the URL/Domain to use the template I created, but it simply leads to the 502 in that case.

This is my .stpl:

server {
listen %ip%:%proxy_ssl_port% ssl;
server_name %domain_idn% %alias_idn%;
error_log /var/log/%web_system%/domains/%domain%.error.log error;

    ssl_certificate     %ssl_pem%;
    ssl_certificate_key %ssl_key%;
    ssl_stapling        on;
    ssl_stapling_verify on;

    # TLS 1.3 0-RTT anti-replay
    if ($anti_replay = 307) { return 307 https://$host$request_uri; }
    if ($anti_replay = 425) { return 425; }

    include %home%/%user%/conf/web/%domain%/nginx.hsts.conf*;

    location ~ /\.(?!well-known\/|file) {
            deny all;
            return 404;
    }

    location / {
            proxy_pass https://%ip%:3001;

            location ~* ^.+\.(%proxy_extensions%)$ {
                    try_files  $uri @fallback;

                    root       %sdocroot%;
                    access_log /var/log/%web_system%/domains/%domain%.log combined;
                    access_log /var/log/%web_system%/domains/%domain%.bytes bytes;

                    expires    max;
            }
    }

    location @fallback {
            proxy_pass https://%ip%:%web_ssl_port%;
    }

    location /error/ {
            alias %home%/%user%/web/%domain%/document_errors/;
    }

    proxy_hide_header Upgrade;

    include %home%/%user%/conf/web/%domain%/nginx.ssl.conf_*;

}

Any solutions?

Have you considered getting your wiki.js site up and running correctly with Cloudflare paused first?

It is a lot easier to troubleshoot one thing at a time.

1 Like

As I said, it does run when hosted via IP & Port. And yes, I had paused Cloudflare and set it to Proxy only in order to see whether it works, but guess what, it does not. This is a common problem with HestiaCP that I’ve run into with other services as well, and know for a fact that it is a misconfiguration of some sorts with the NGINX Template. Cloudflare is not the problem, as the site loads only via IP & Port, and when I try accessing it via the Domain/URL even with Cloudflare disabled, it does not load properly because NGINX does not proxy correctly.

EDIT: So I suppose the question is, which logs can I check in order to properly figure out why NGINX does not proxy correctly, and what would I have to reconfigure in order for it work.

proxy_pass is for sure non ssl, use https://%ip%:3001 and it should work. Just in case you’ve setup ssl on that port, maybe try without - as for local communication, there is usualy no need for encryption.

But that’s already what I have in " ```
proxy_pass https://%ip%:3001;

Ah, you want me to set it to "http" then?

sorry, http://%ip%:3001 ofc.

2 Likes

Thank you Raphael, I’ll try that :slight_smile:

EDIT: Also in the “.stpl” which is for SSL, right?

EDIT 2: Stupid me, yes of course, that is the only file with “HTTPS” :man_facepalming:

That was indeed the solution, thank you so much! Now only to the issue where I have no images load if I do it via URL/Domain, how come? The page is blank unless I enter it via IP & Port :frowning:

I keep getting an “Error 404” when trying to access the content via the URL:

The document loads, but the scripts and CSS and whatnot for some reason simply do not. Any suggestions here?

edit the web domain and empty the cache extension list to disable caching. Mayve that’s the issue.

You mean these here I assume:

2nd reply:

How did you know!? That was the solution again…
I removed all extensions and purged cache, and it then worked… Man I wish I had your knowledge and brain… Can I steal it :stuck_out_tongue: ?

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