🚦 NGINX Configuration¶
Hosting Meerschaum behind NGINX is a great way set up TLS/SSL with Let's Encrypt (certbot
). There are several important goals when setting up forwarding:
- Proxy pass requests to your internal Meerschaum API instance (e.g. http://localhost:8000).
- Set upgrade headers for requests to locations ending in
/ws
or/websocket
. - Increase the
client_max_body_size
limit (so larger chunks may be synced).
Add a Subdomain¶
First, add an A record to your domain's DNS nameserver for the subdomain mrsm
and set it to the public IPv4 address of your NGINX server.
It's a good idea to add an AAAA DNS record as well for your server's IPv6 address.
Next, create mrsm.conf
in /etc/nginx/conf.d
(Ubuntu/Debian: /etc/nginx/sites-available
) to add a new subdomain mrsm
. Paste the example configuration below and replace DOMAIN
with your root domain.
This example assumes you are running NGINX on the same machine as your API instance (e.g. the stack). Modify the proxy pass URLs based on your situation.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
|
Reload NGINX to apply your new file:
1 |
|
You should now be able to access http://mrsm.your-domain.com
. If so, continue below to activate HTTPS for your subdomain:
Add TLS/SSL¶
Thanks to Let's Encrypt, adding HTTPS is easier than ever. Follow these steps:
- Install
certbot
. - Run
sudo certbot --nginx
. The wizard will ask which domain to add HTTPS to; select your newmrsm.your-domain.com
or just press Enter.
If all went well, https://mrsm.your-domain.com
should be active! Below is an example of what the modified mrsm.conf
should look like:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
|