Last active
August 28, 2023 14:23
-
-
Save umutyerebakmaz/465b0f177dbb88c8c99fd0438b0d7151 to your computer and use it in GitHub Desktop.
nginx proxy, custom daemon service, express-apollo, nodejs deployment formerly 2023 updated
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
[Unit] | |
Description=apollo.service | |
After=network.target | |
[Service] | |
User=root | |
Group=root | |
ExecStart=/bin/bash -c 'source /root/.nvm/nvm.sh && nvm use v16.20.2 && cd /var/www/server && yarn start' | |
Environment=NODE_ENV=production | |
StandardOutput=syslog | |
StandardError=syslog | |
SyslogIdentifier=apollo | |
Restart=always | |
RestartSec=10 | |
[Install] | |
WantedBy=multi-user.target |
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
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://[droplet-ip]: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 | |
} |
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
{ | |
"scripts": { | |
"start": "NODE_ENV=production 'ts-node' -r tsconfig-paths/register src/server.ts", | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment