Created
February 28, 2017 07:17
-
-
Save minhchu/a5d06d8b00ccb6bd893704f088bb4320 to your computer and use it in GitHub Desktop.
Nginx and Express Morgan configurations for logging in production
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const app = express(); | |
... | |
app.set('trust proxy', true); | |
if (process.env.ENVIRONMENT == 'development') { | |
app.use(logger('dev')); | |
} else { | |
app.use(logger('combined')); | |
} | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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