Skip to content

Instantly share code, notes, and snippets.

@gtzilla
Last active May 3, 2020 06:18
Show Gist options
  • Save gtzilla/ccf2155afccb019e7f1d2f5a7e4d3777 to your computer and use it in GitHub Desktop.
Save gtzilla/ccf2155afccb019e7f1d2f5a7e4d3777 to your computer and use it in GitHub Desktop.
NGINX serving JavaScript SPA (Single Page Application), locally via docker-compose
module.exports = {
env: {
browser: true,
es6: true
},
extends: [
'plugin:react/recommended',
'semistandard'
],
settings:{
react:{
version:'detect'
}
},
globals: {
"_": 'readonly',
React: 'readonly',
ReactDOM: 'readonly',
Atomics: 'readonly',
SharedArrayBuffer: 'readonly'
},
parserOptions: {
ecmaFeatures: {
jsx: true
},
ecmaVersion: 2020,
sourceType: 'module'
},
plugins: [
'react'
],
rules: {
}
}
version: '3.7'
services:
nginx:
image: "nginx:latest"
container_name: 'nginx'
hostname: 'nginx'
ports:
- "8888:80"
volumes:
- ./nginx.local.conf:/etc/nginx/conf.d/default.conf
- ./node_modules:/mnt/vendor
- ./static:/mnt/static
server {
listen 80;
server_name _;
root /mnt/static/html;
index index.html;
location /static {
add_header Last-Modified $date_gmt;
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
if_modified_since off;
expires off;
etag off;
alias /mnt/static/;
allow all;
}
location /static/js/vendor {
alias /mnt/vendor;
allow all;
}
location ^~ / {
# https://stackoverflow.com/questions/40243633/disable-nginx-cache-for-javascript-files
proxy_ignore_headers Cache-Control;
add_header Last-Modified $date_gmt;
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
if_modified_since off;
expires off;
etag off;
sendfile on;
sendfile_max_chunk 1m;
tcp_nopush on;
keepalive_timeout 65;
alias /mnt/app/static/html/;
try_files $uri /index.html;
}
location / {
proxy_ignore_headers Cache-Control;
add_header Last-Modified $date_gmt;
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
if_modified_since off;
expires off;
etag off;
sendfile on;
sendfile_max_chunk 1m;
tcp_nopush on;
keepalive_timeout 65;
index index.html;
alias /mnt/static/html/;
}
}
{
"version": "1.0.0",
"dependencies": {
"moment": "^2.24.0",
"navigo": "^7.1.2",
"react": "^16.13.0",
"react-dom": "^16.13.0",
"underscore": "^1.9.2"
},
"devDependencies": {
"eslint": "^6.8.0",
"eslint-config-semistandard": "^15.0.0",
"eslint-config-standard": "^14.1.0",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-react": "^7.19.0",
"eslint-plugin-standard": "^4.0.1",
"semistandard": "^14.2.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment