From 889ab57eec48c8a2057ce4d003a0bea41e0a8aa8 Mon Sep 17 00:00:00 2001 From: Arthur Date: Wed, 27 Mar 2024 11:11:23 -0700 Subject: [PATCH] 15154 review comments - merge nginx conf --- contrib/nginx.conf | 8 ++++++++ contrib/uwsgi/nginx.conf | 31 ------------------------------- docs/installation/uwsgi.md | 18 ++++++++++++++---- 3 files changed, 22 insertions(+), 35 deletions(-) delete mode 100644 contrib/uwsgi/nginx.conf diff --git a/contrib/nginx.conf b/contrib/nginx.conf index 34821cd52..67db188e3 100644 --- a/contrib/nginx.conf +++ b/contrib/nginx.conf @@ -18,6 +18,14 @@ server { proxy_set_header X-Forwarded-Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Proto $scheme; + # comment the lines above and uncomment the lines below if using uWSGI + # 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; + } } diff --git a/contrib/uwsgi/nginx.conf b/contrib/uwsgi/nginx.conf deleted file mode 100644 index ad8ee9e31..000000000 --- a/contrib/uwsgi/nginx.conf +++ /dev/null @@ -1,31 +0,0 @@ -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 / { - 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; -} diff --git a/docs/installation/uwsgi.md b/docs/installation/uwsgi.md index 1f1115d0d..39f1a4181 100644 --- a/docs/installation/uwsgi.md +++ b/docs/installation/uwsgi.md @@ -75,10 +75,20 @@ Once you've verified that the WSGI workers are up and running, move on to HTTP s ## HTTP Server Installation -For server installation, you will want to follow the NetBox [HTTP Server Setup](5-http-server.md) guide, however when copying the configuration file, instead of the default one for gunicorn you will want to use the provided uWSGI one: - -Once nginx is installed, copy the nginx configuration file provided by NetBox to `/etc/nginx/sites-available/netbox`. Be sure to replace `netbox.example.com` with the domain name or IP address of your installation. (This should match the value configured for `ALLOWED_HOSTS` in `configuration.py`.) +For server installation, you will want to follow the NetBox [HTTP Server Setup](5-http-server.md) guide, however after copying the configuration file, you will need to edit the file and change the `location` section to uncomment the uWSGI parameters: ```no-highlight -sudo cp /opt/netbox/contrib/uwsgi/nginx.conf /etc/nginx/sites-available/netbox + location / { + # 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; + # comment the lines above and uncomment the lines below if using uWSGI + 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; + } ```