Skip to content

Instantly share code, notes, and snippets.

@umutyerebakmaz

umutyerebakmaz/domain.com

Last active Sep 8, 2020
Embed
What would you like to do?
nginx proxy, daemon service, express-apollo, nodejs deployment formerly 2020 updated
map $http_upgrade $type {
default "web";
websocket "ws";
}
server {
root /var/www/domain.com/dist/browser;
index index.html index.htm index.nginx-debian.html;
charset utf-8;
server_name domain.com www.domain.com;
location / {
try_files $uri $uri/ /index.html;
}
location /graphql {
proxy_pass http://[droplet-ip]:4000/graphql;
proxy_set_header Host $host;
proxy_read_timeout 60;
proxy_connect_timeout 60;
proxy_redirect off;
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;
}
location /images {
proxy_pass http://[droplet-ip]:4000;
proxy_set_header Host $host;
proxy_read_timeout 60;
proxy_connect_timeout 60;
proxy_redirect off;
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;
}
location @ws {
proxy_pass http://127.0.0.1:6001;
proxy_set_header Host $host;
proxy_read_timeout 60;
proxy_connect_timeout 60;
proxy_redirect off;
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;
}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/domain.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/domain.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = www.domain.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = domain.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
listen [::]:80;
server_name domain.com www.domain.com;
return 404; # managed by Certbot
}
[Unit]
Description=express-graphql.service
After=network.target
[Service]
User=root
Group=root
WorkingDirectory=/var/www/server
ExecStart=/usr/bin/yarn start
Environment=NODE_ENV=production
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=express-graphql
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
{
"name": "express-apollo-backend",
"version": "1.0.0",
"description": "Apollo, GraphQL, TsNode, TypeORM, TypeGraphQL, Postgres",
"author": "Umut Yerebakmaz",
"main": "server.ts",
"license": "MIT",
"private": true,
"scripts": {
"start": "NODE_ENV=production 'ts-node' src/server.ts"
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment