Skip to content

Commit

Permalink
nginx.conf: remove OS-specific paths (getodk#621)
Browse files Browse the repository at this point in the history
* nginx.conf: remove OS-specific paths

* README: include PWD in nginx paths

* Rename tmp dir to .nginx

* Remove unknown mime types/extensions

* Fix .gitignore

Co-authored-by: alxndrsn <alxndrsn>
  • Loading branch information
alxndrsn authored Jul 12, 2022
1 parent 8274fc0 commit 3078965
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ npm-debug.log*
*.njsproj
*.sln
*.sw?

/.nginx/*
!/.nginx/.gitkeep
Empty file added .nginx/.gitkeep
Empty file.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ First, install Node.js 14.

Next, install dependencies by running `npm install`.

Install NGINX. Depending on your operating system and how you install NGINX, you may need to change the absolute paths in the development [`nginx.conf`](/nginx.conf).
Install NGINX.

You will also need to set up [ODK Central Backend](https://github.com/getodk/central-backend). You will need to create a user using an ODK Central Backend command line script. You will probably also want to promote that user to a sitewide administrator.

Expand All @@ -48,10 +48,10 @@ Next, build ODK Central Frontend files for development by running `npm run dev`.
Finally, run NGINX by changing the working directory to the root directory of the repository, then typing the following:

```bash
nginx -c "$PWD/nginx.conf" -p "$PWD/dist/"
nginx -c "$PWD/nginx.conf" -p "$PWD"
```

NGINX effectively places ODK Central Frontend and ODK Central Backend at the same origin, avoiding cross-origin requests. We specify `-p "$PWD/dist/"` so that relative paths in [`nginx.conf`](/nginx.conf) are relative to `dist/`.
NGINX effectively places ODK Central Frontend and ODK Central Backend at the same origin, avoiding cross-origin requests. We specify `-p "$PWD"` so that relative paths in [`nginx.conf`](/nginx.conf) are relative to the repository root.

ODK Central Frontend will be available on port 8989.

Expand Down
31 changes: 25 additions & 6 deletions nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,34 @@
#
# One difference between this file and the configuration for production is that
# this configuration does not support request body decompression.
daemon off;
error_log stderr;
pid ./.nginx/nginx.pid;

events {
}
http {
# This path may be different on your local computer depending on your OS and
# how you installed nginx.
include /usr/local/etc/nginx/mime.types;
access_log ./.nginx/nginx-access.log;

types {
text/html html htm shtml;
text/css css;
text/xml xml;
application/javascript js;

text/plain txt;

image/png png;
image/x-icon ico;
image/svg+xml svg svgz;

application/font-woff woff;
application/json json;
application/vnd.ms-excel xls;
application/zip zip;

application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx;
}

map $sent_http_set_cookie $session_cookie {
~^__Host-(session=.+)$ $1;
Expand Down Expand Up @@ -62,9 +83,7 @@ http {
}

location / {
# Specify the dist/ directory of the repository to `nginx -p` so that . is
# relative to dist/.
root .;
root ./dist;

location /index.html {
add_header Cache-Control no-cache;
Expand Down

0 comments on commit 3078965

Please sign in to comment.