forked from rDrama/rDrama
Serve static user content with nginx.
parent
0dfa4525fa
commit
81dda4f6cc
|
@ -297,6 +297,10 @@ def static_service(path):
|
|||
|
||||
return resp
|
||||
|
||||
### BEGIN FALLBACK ASSET SERVING
|
||||
# In production, we have nginx serve these locations now.
|
||||
# These routes stay for local testing. Requests don't reach them on prod.
|
||||
|
||||
@app.get('/images/<path>')
|
||||
@app.get('/hostedimages/<path>')
|
||||
@app.get("/static/images/<path>")
|
||||
|
@ -325,6 +329,8 @@ def audio(path):
|
|||
resp.headers.add("Cache-Control", "public, max-age=3153600")
|
||||
return resp
|
||||
|
||||
### END FALLBACK ASSET SERVING
|
||||
|
||||
@app.get("/robots.txt")
|
||||
def robots_txt():
|
||||
return send_file("assets/robots.txt")
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
root /;
|
||||
try_files $uri =404;
|
||||
add_header 'Cache-Control' "public, max-age=3153600";
|
||||
|
||||
sendfile on;
|
||||
sendfile_max_chunk 1m;
|
||||
tcp_nopush on;
|
||||
directio 4m;
|
66
nginx.txt
66
nginx.txt
|
@ -1,28 +1,42 @@
|
|||
server {
|
||||
server_name rdrama.net;
|
||||
client_max_body_size 100m;
|
||||
listen 443 ssl;
|
||||
listen [::]:443 ssl;
|
||||
ssl_certificate '/rdrama.pem';
|
||||
ssl_certificate_key '/rdrama.key';
|
||||
proxy_set_header Host $host;
|
||||
server_name rdrama.net;
|
||||
client_max_body_size 100m;
|
||||
listen 443 ssl;
|
||||
listen [::]:443 ssl;
|
||||
ssl_certificate '/rdrama.pem';
|
||||
ssl_certificate_key '/rdrama.key';
|
||||
proxy_set_header Host $host;
|
||||
|
||||
location / {
|
||||
proxy_pass http://localhost:5000/;
|
||||
}
|
||||
location /socket.io {
|
||||
include proxy_params;
|
||||
proxy_http_version 1.1;
|
||||
proxy_buffering off;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "Upgrade";
|
||||
proxy_pass http://127.0.0.1:5001/socket.io;
|
||||
}
|
||||
location /chat {
|
||||
proxy_pass http://127.0.0.1:5001/chat;
|
||||
}
|
||||
error_page 502 = /error_page/502.html;
|
||||
location /error_page/ {
|
||||
alias /rDrama/files/templates/errors/;
|
||||
}
|
||||
}
|
||||
location / {
|
||||
proxy_pass http://localhost:5000/;
|
||||
}
|
||||
location /socket.io {
|
||||
include proxy_params;
|
||||
proxy_http_version 1.1;
|
||||
proxy_buffering off;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "Upgrade";
|
||||
proxy_pass http://127.0.0.1:5001/socket.io;
|
||||
}
|
||||
location /chat {
|
||||
proxy_pass http://127.0.0.1:5001/chat;
|
||||
}
|
||||
|
||||
location /images/ {
|
||||
include includes/serve-static;
|
||||
}
|
||||
location /videos/ {
|
||||
include includes/serve-static;
|
||||
}
|
||||
location /audio/ {
|
||||
include includes/serve-static;
|
||||
}
|
||||
location /asset_submissions/ {
|
||||
include includes/serve-static;
|
||||
}
|
||||
|
||||
error_page 502 = /error_page/502.html;
|
||||
location /error_page/ {
|
||||
alias /rDrama/files/templates/errors/;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,9 @@ chown postgres:postgres /etc/postgresql/14/main/pg_hba.conf
|
|||
|
||||
sudo rm /etc/nginx/sites-available -r
|
||||
sudo rm /etc/nginx/sites-enabled/default
|
||||
sudo mkdir /etc/nginx/includes
|
||||
sudo cp nginx.txt /etc/nginx/sites-enabled/1
|
||||
sudo cp nginx-serve-static.txt /etc/nginx/includes/serve-static
|
||||
|
||||
psql -U postgres -f schema.sql postgres
|
||||
psql -U postgres -f seed-db.sql postgres
|
||||
|
|
Loading…
Reference in New Issue