Skip to content

Instantly share code, notes, and snippets.

@MuttakinHasib
Created July 20, 2022 05:23
Show Gist options
  • Save MuttakinHasib/c9c6f8252ea4e56a4122da7d2c7f1459 to your computer and use it in GitHub Desktop.
Save MuttakinHasib/c9c6f8252ea4e56a4122da7d2c7f1459 to your computer and use it in GitHub Desktop.
server {
root /var/www/html; root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name beweddy.com www.beweddy.com;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
add_header Access-Control-Allow-Origin *;
proxy_pass http://localhost:3000; #whatever port your app runs on
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 ^~ /api/ {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
add_header Access-Control-Allow-Origin *;
proxy_pass http://localhost:1337/; #whatever port your app runs on
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/beweddy.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/beweddy.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.beweddy.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = beweddy.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80 default_server;
listen [::]:80 default_server;
server_name beweddy.com www.beweddy.com;
return 404; # managed by Certbot
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment