DEV: Add 'include' statements for outlets in nginx config (#30929)

The 'include' statements serve as extension outlets that are populated
by discourse/discourse_docker.
This commit is contained in:
Bianca Nenciu
2025-02-04 15:21:33 +02:00
committed by GitHub
parent 65324b6e5d
commit 649505d869

View File

@@ -1,14 +1,13 @@
# Additional MIME types that you'd like nginx to handle go in here # Additional MIME types that you'd like nginx to handle go in here
types { types {
text/csv csv; text/csv csv;
application/wasm wasm; application/wasm wasm;
font/ttf ttf; font/ttf ttf;
font/otf otf; font/otf otf;
} }
upstream discourse { upstream discourse {
server unix:/var/www/discourse/tmp/sockets/nginx.http.sock; server 127.0.0.1:3000;
server unix:/var/www/discourse/tmp/sockets/nginx.https.sock;
} }
# inactive means we keep stuff around for 1440m minutes regardless of last access (1 week) # inactive means we keep stuff around for 1440m minutes regardless of last access (1 week)
@@ -40,11 +39,15 @@ geo $bypass_cache {
::1 1; ::1 1;
} }
server { include conf.d/outlets/before-server/*.conf;
server {
access_log /var/log/nginx/access.log log_discourse; access_log /var/log/nginx/access.log log_discourse;
listen 80; listen 80;
include conf.d/outlets/server/*.conf;
gzip on; gzip on;
gzip_vary on; gzip_vary on;
gzip_min_length 1000; gzip_min_length 1000;
@@ -52,19 +55,7 @@ server {
gzip_types application/json text/css text/javascript application/x-javascript application/javascript image/svg+xml application/wasm font/ttf font/otf; gzip_types application/json text/css text/javascript application/x-javascript application/javascript image/svg+xml application/wasm font/ttf font/otf;
gzip_proxied any; gzip_proxied any;
# Uncomment and configure this section for HTTPS support server_name _;
# NOTE: Put your ssl cert in your main nginx config directory (/etc/nginx)
#
# rewrite ^/(.*) https://enter.your.web.hostname.here/$1 permanent;
#
# listen 443 ssl;
# ssl_certificate your-hostname-cert.pem;
# ssl_certificate_key your-hostname-cert.key;
# ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
# ssl_ciphers HIGH:!aNULL:!MD5;
#
server_name enter.your.web.hostname.here;
server_tokens off; server_tokens off;
sendfile on; sendfile on;
@@ -181,7 +172,6 @@ server {
} }
location ~ ^/uploads/ { location ~ ^/uploads/ {
# NOTE: it is really annoying that we can't just define headers # NOTE: it is really annoying that we can't just define headers
# at the top level and inherit. # at the top level and inherit.
# #
@@ -206,14 +196,17 @@ server {
add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Origin *;
try_files $uri =404; try_files $uri =404;
} }
# this allows us to bypass rails # this allows us to bypass rails
location ~* \.(gif|png|jpg|jpeg|bmp|tif|tiff|ico|webp|avif)$ { location ~* \.(gif|png|jpg|jpeg|bmp|tif|tiff|ico|webp|avif)$ {
add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Origin *;
try_files $uri =404; try_files $uri =404;
} }
# SVG needs an extra header attached # SVG needs an extra header attached
location ~* \.(svg)$ { location ~* \.(svg)$ {
} }
# thumbnails & optimized images # thumbnails & optimized images
location ~ /_?optimized/ { location ~ /_?optimized/ {
add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Origin *;
@@ -291,6 +284,8 @@ server {
} }
location @discourse { location @discourse {
include conf.d/outlets/discourse/*.conf;
proxy_set_header Host $http_host; proxy_set_header Host $http_host;
proxy_set_header X-Request-Start "t=${msec}"; proxy_set_header X-Request-Start "t=${msec}";
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-IP $remote_addr;
@@ -301,5 +296,4 @@ server {
proxy_set_header Client-Ip ""; proxy_set_header Client-Ip "";
proxy_pass http://discourse; proxy_pass http://discourse;
} }
} }