Home > Software design >  Map local application behind public subresource
Map local application behind public subresource

Time:06-11

I'm running Joplin Server on my Raspi4 under http://127.0.0.1:23000 and on the Raspi I can successfully access the web app.

Since I don't want to publish the port 23000, I want Joplin Server to be accessible via https://myRaspi/joplinServer. Therefore I'm using Nginx.

I tried at first with:

location /joplinServer {
  proxy_pass http://127.0.0.1:22300;
}

Now when calling https://myRaspi/joplinServer from any other machine, Nginx keeps the subresource /joplinServer, resulting in an "inner call" to http://127.0.0.1:22300/joplinServer - which does not exist, sure, because Joplin Server itself knows nothing about the subresource and seems to have troubles with handling it.

I also tried this:

location = /joplinServer {
  rewrite ^/joplinServer?$ http://127.0.0.1:22300 break;
}

But now every external requests to https://myRaspi/joplinServer ends up as http://127.0.0.1:22300 on my machine which does obviously not work.

So what do I have to configure on Nginx to make my setting work?

Thanks in advance!

CodePudding user response:

This post gave me the solution, which looks like this:

location /joplinServer/ {
   proxy_redirect off;
   rewrite     ^/joplinServer/(.*)$ /$1 break;
   proxy_pass http://127.0.0.1:22300;
}
  • Related