Nginx: link to another server on a different port

177 views Asked by At

I have an Nginx server/site installed on my Raspberry pi and runs on https://example.com.

I also have a Calibre ebook server on the same Raspberry pi that runs on https://example.com:8585. Having a port number at the end is ugly and not easy to remember.

I want my Calibre server to be accessible at https://example.com/calibre

Is there a setting in the Nginx server that I can tweak to achieve this? I am new to web server setups. Any suggestions would be helpful. Thanks!

1

There are 1 answers

0
YuriB. On

Two simple ways. First - create location /calibre which cuts "/calibre" and pass requests to 8585 (trailng slash at end of proxy_pass is important)

server {
  ...

  location /calibre {
    proxy_pass https://example.com:8585/;
  }

  ...
}

Second (and better I think) way - to create subdomain calibre.example.com in your DNS and make another server{} for calibre like this

server {
  listen 443 ssl;

  ... ssl options here...

  server_name calibre.example.com;
  location / {
    proxy_pass https://example.com:8585;
  }
}