Skip to content

Instantly share code, notes, and snippets.

@minhchu
Created February 28, 2017 07:17
Show Gist options
  • Save minhchu/a5d06d8b00ccb6bd893704f088bb4320 to your computer and use it in GitHub Desktop.
Save minhchu/a5d06d8b00ccb6bd893704f088bb4320 to your computer and use it in GitHub Desktop.
Nginx and Express Morgan configurations for logging in production
'use strict';
const app = express();
...
app.set('trust proxy', true);
if (process.env.ENVIRONMENT == 'development') {
app.use(logger('dev'));
} else {
app.use(logger('combined'));
}
...
server {
listen 80;
server_name domain.com;
location / {
return 301 https://$server_name$request_uri;
}
}
server {
listen 443 ssl;
server_name domain.com;
ssl_certificate /etc/letsencrypt/live/domain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/domain.com/privkey.pem;
add_header Strict-Transport-Security "max-age=31536000";
client_max_body_size 100M;
location / {
proxy_pass http://localhost:3000;
proxy_set_header X-Forwarded-For $remote_addr;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment