Last active
October 29, 2019 01:00
-
-
Save FaisalAl-Tameemi/827e0a3b86f3d28b578ecaaab08398ab to your computer and use it in GitHub Desktop.
UI Server w. ExpressJS
This file contains hidden or 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
[Unit] | |
Description=Ben Will Cabinets | |
[Service] | |
ExecStart=/var/www/construction-website/server.js | |
Restart=always | |
User=nobody | |
Group=nogroup | |
Environment=PATH=/usr/bin:/usr/local/bin | |
Environment=NODE_ENV=production | |
Environment=PORT=8080 | |
WorkingDirectory=/var/www/construction-website | |
[Install] | |
WantedBy=multi-user.target |
This file contains hidden or 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
events { | |
} | |
http { | |
server { | |
listen 80; | |
server_name www.benwillcabinets.com; | |
return 301 https://$host$request_uri; | |
} | |
server { | |
listen 443 ssl; | |
server_name benwillcabinets.com; | |
ssl_certificate /etc/letsencrypt/live/benwillcabinets.com/fullchain.pem; | |
ssl_certificate_key /etc/letsencrypt/live/benwillcabinets.com/privkey.pem; | |
location / { | |
proxy_pass http://localhost:8080; | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection 'upgrade'; | |
proxy_set_header Host $host; | |
proxy_cache_bypass $http_upgrade; | |
} | |
} | |
} |
This file contains hidden or 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
#!~/.nvm/versions/node/v10.16.3/bin/node | |
const path = require('path'); | |
const express = require('express'); | |
const app = express(); | |
app.set('port', (process.env.PORT || 8080)); | |
app.set('view engine', 'html'); | |
app.enable('trust proxy'); | |
app.use(express.static(path.join(__dirname, '/build'))); | |
// for any other route not available in /build, send the index.html page | |
app.use((req, res, next) => { | |
// disable cache in response | |
res.sendFile(`${__dirname}/build/index.html`); | |
}); | |
// start the server | |
app.listen(app.get('port'), () => { | |
console.log(`Server start on port ${app.get('port')}...`); | |
}); | |
module.exports = app; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment