Skip to content

Commit 5d25c4a

Browse files
authored
Merge pull request #157 from cmu-delphi/update-nginx-proxy-config
Changes the behavior of Nginx when configured to serve static files
2 parents 8b02fe8 + f60d64f commit 5d25c4a

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

README.md

+9-2
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,14 @@ Open `http://localhost:8000` to view it in the browser
8282
Though probably not necessary in most cases, if you want to test/modify/emulate how this will run in production you can:
8383

8484
- In `.env` set:
85-
```
85+
86+
```shell
8687
DEBUG = 'False'
8788
```
89+
8890
- Modify the app container's command in `docker-compose.yaml` to run:
89-
```
91+
92+
```shell
9093
gunicorn signal_documentation.wsgi:application --bind 0.0.0.0:8000"
9194
9295
*(Essentially you'll replace just the last line of the command, switching out the "runserver" line)
@@ -96,6 +99,10 @@ Open `http://localhost` to view it in the browser. In this usage your request wi
9699
97100
The primary use case for this will be when making changes to the Nginx container image that runs in production and hosts the static file content, or also if making changes to the Gunicorn config.
98101
102+
Additionally, though again not required for local development, you can also specify an env var of `MAIN_PAGE = $name`, and the app will be served at `http://localhost:8000/$name` (if running in debug mode), or if you've set `DEBUG = 'False'` to run it in Nginx/production mode at `http://localhost/$name/`. Note the ending slash when in Nginx/production mode _and_ using the `MAIN_PAGE` env var.
103+
104+
The primary use case is so that we have flexibility to serve the application at something other than the "bare" URL, though doing this is not necessary for local development.
105+
99106
Changes of this sort should be carefully evaluated as they may require interaction with systems managed by devops folks.
100107
101108
## [Django admin](https://docs.djangoproject.com/en/4.1/ref/contrib/admin/) web interface (user should be `is_staff` or `is_superuser`)

nginx/default.conf.template

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
server {
22
listen 80;
33
server_name sdnginx;
4-
5-
location /static/ {
4+
location ~* /static/(.*)$ {
65
autoindex on;
7-
alias /staticfiles/;
6+
alias /staticfiles/$1;
87
}
98

109
location / {

0 commit comments

Comments
 (0)