From 3078965dc8ad86b34944476d0dd84475487d44ab Mon Sep 17 00:00:00 2001 From: Alex Anderson <191496+alxndrsn@users.noreply.github.com> Date: Tue, 12 Jul 2022 18:47:21 +0300 Subject: [PATCH] nginx.conf: remove OS-specific paths (#621) * 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 --- .gitignore | 3 +++ .nginx/.gitkeep | 0 README.md | 6 +++--- nginx.conf | 31 +++++++++++++++++++++++++------ 4 files changed, 31 insertions(+), 9 deletions(-) create mode 100644 .nginx/.gitkeep diff --git a/.gitignore b/.gitignore index f382cd379..71a776fa7 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,6 @@ npm-debug.log* *.njsproj *.sln *.sw? + +/.nginx/* +!/.nginx/.gitkeep diff --git a/.nginx/.gitkeep b/.nginx/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/README.md b/README.md index 124cb4369..317b43ecd 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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. diff --git a/nginx.conf b/nginx.conf index 18473e790..09c5ec361 100644 --- a/nginx.conf +++ b/nginx.conf @@ -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; @@ -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;