Skip to content
This repository was archived by the owner on Aug 14, 2024. It is now read-only.

Commit 0c10943

Browse files
authored
feat: add NGINX as a reverse proxy example (#1257)
1 parent 8248225 commit 0c10943

File tree

1 file changed

+53
-4
lines changed

1 file changed

+53
-4
lines changed

src/docs/self-hosted/reverse-proxy.mdx

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: 'Self-Hosted Reverse Proxy'
33
---
44

5-
Adding a reverse proxy in front of your Sentry deployment is strongly recommended for one big reason: you can fine tune every configuration to fit your current setup. A dedicated reverse proxy that does SSL/TLS termination that also forwards the client IP address as Docker Compose internal network (as this is [close to impossible to get otherwise)](https://github.com/getsentry/self-hosted/issues/554) would give you the best Sentry experience.
5+
Adding a reverse proxy in front of your Sentry deployment is strongly recommended for one big reason: you can fine tune every configuration to fit your current setup. A dedicated reverse proxy that does SSL/TLS termination that also forwards the client IP address as Docker Compose internal network (as this is [close to impossible to get otherwise](https://github.com/getsentry/self-hosted/issues/554)) would give you the best Sentry experience.
66

77
Once you have setup a reverse proxy to your Sentry instance, you should modify the `system.url-prefix` in the `config.yml` file to match your new URL and protocol. You should also update the SSL/TLS section in the `sentry/sentry.conf.py` script, otherwise you may get CSRF-related errors when performing certain actions such as configuring integrations.
88

@@ -36,15 +36,64 @@ Endpoint for health checks is available on `/_health/` endpoint using HTTP proto
3636

3737
## Reverse Proxy Examples
3838

39-
<!-- ### NGINX
39+
### NGINX
4040

41-
Put some NGINX config here... Give link to tune NGINX.
41+
We recommend installing NGINX since that's what we are using on [sentry.io](https://sentry.io/).
42+
43+
```nginx
44+
error_log /var/log/nginx/error.log warn;
45+
46+
# generated 2024-04-29, Mozilla Guideline v5.7, nginx 1.24.0, OpenSSL 3.0.13, modern configuration, no HSTS, no OCSP
47+
# https://ssl-config.mozilla.org/#server=nginx&version=1.24.0&config=modern&openssl=3.0.13&hsts=false&ocsp=false&guideline=5.7
48+
server {
49+
listen 443 ssl http2;
50+
listen [::]:443 ssl http2;
51+
52+
ssl_certificate /etc/letsencrypt/live/sentry.yourcompany.com/fullchain.pem;
53+
ssl_certificate_key /etc/letsencrypt/live/sentry.yourcompany.com/privkey.pem;
54+
ssl_session_timeout 1d;
55+
ssl_session_cache shared:MozSSL:10m; # about 40000 sessions
56+
ssl_session_tickets off;
57+
58+
ssl_dhparam /etc/letsencrypt/ffdhe2048.txt;
59+
60+
# modern configuration
61+
ssl_protocols TLSv1.3;
62+
ssl_prefer_server_ciphers off;
63+
64+
proxy_buffering on;
65+
proxy_buffer_size 128k;
66+
proxy_buffers 4 256k;
67+
68+
location / {
69+
include proxy_params;
70+
proxy_pass http://your-sentry-ip:9000;
71+
}
72+
}
73+
74+
server {
75+
server_name sentry.yourcompany.com;
76+
listen 80;
77+
listen [::]:80;
78+
79+
root /var/www/html;
80+
# Allow certbot to do http-01 challenges
81+
location /.well-known/ {
82+
try_files $uri =404;
83+
}
84+
# otherwise redirect to HTTPS
85+
location / {
86+
return 301 https://$host$request_uri;
87+
}
88+
}
89+
```
90+
91+
To use NGINX with ACME server such as Let's Encrypt, refer to this [blog post by Nginx](https://www.nginx.com/blog/using-free-ssltls-certificates-from-lets-encrypt-with-nginx/).
4292

4393
It is also recommended to fine tune your NGINX for some performance benefits. You can refer to these blog posts from NGINX:
4494

4595
- [Tuning NGINX for Performance - NGINX](https://www.nginx.com/blog/tuning-nginx/)
4696
- [Performance Tuning - Tips & Tricks - NGINX](https://www.nginx.com/blog/performance-tuning-tips-tricks/)
47-
-->
4897

4998
### Caddy
5099

0 commit comments

Comments
 (0)