The original post: /r/nginx by /u/alohl669 on 2024-08-11 20:46:26.
Hi! I’m installing a Django application with gunicorn.
Their instructions use nginx to serve the application, the problem is they never weigh using nginx in a separate server, always using localhost.
I could install nginx on this machine and change my DNS zone but… I already have precisely a nginx server working as a reverse proxy to avoid installing another.
ok, let us see the problem
this is their nginx localhost configuration
server {
listen [::]:443 ssl ipv6only=off;
# CHANGE THIS TO YOUR SERVER'S NAME
server_name netbox.example.com;
ssl_certificate /etc/ssl/certs/netbox.crt;
ssl_certificate_key /etc/ssl/private/netbox.key;
client_max_body_size 25m;
location /static/ {
alias /opt/netbox/netbox/static/;
}
location / {
# Remove these lines if using uWSGI instead of Gunicorn
proxy_pass http://127.0.0.1:8001;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
# Uncomment these lines if using uWSGI instead of Gunicorn
# include uwsgi_params;
# uwsgi_pass 127.0.0.1:8001;
# uwsgi_param Host $host;
# uwsgi_param X-Real-IP $remote_addr;
# uwsgi_param X-Forwarded-For $proxy_add_x_forwarded_for;
# uwsgi_param X-Forwarded-Proto $http_x_forwarded_proto;
}
}
server {
# Redirect HTTP traffic to HTTPS
listen [::]:80 ipv6only=off;
server_name _;
return 301 https://$host$request_uri;
}
And this is mine
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name netbox.example.coml;
ssl_certificate /etc/nginx/custom_certs/fullchain-example.com.crt;
ssl_certificate_key /etc/nginx/custom_certs/example.com.key;
ssl_trusted_certificate /etc/nginx/custom_certs/cachain-example.com.crt;
include snippets/ssl-params.conf;
client_max_body_size 25m;
location /static/ {
alias /opt/netbox/netbox/static/;
}
location / {
proxy_pass http://10.10.10.17:8001;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
server {
# Redirect HTTP traffic to HTTPS
listen 80;
listen [::]:80;
server_name netbox.example.com;
return 301 https://$host$request_uri;
}
this could be a simple graphical approximation
Of course, I know it is nonsense to try serving static files from the filesystem of another server.
How could I resolve this? Any idea?
You must log in or register to comment.