Last active
September 1, 2023 07:31
-
-
Save maplerichie/fd5bb4ef82a9e4bacaff741b39b1a199 to your computer and use it in GitHub Desktop.
[NGINX Setup] Debian Nginx #nginx
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
https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-20-04 | |
https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-20-04 | |
https://www.digitalocean.com/community/tutorials/how-to-host-a-website-using-cloudflare-and-nginx-on-ubuntu-20-04 | |
##################NGINX SETUP####################### | |
sudo apt update | |
sudo apt install nginx -y | |
sudo apt install certbot python3-certbot-nginx -y | |
sudo ufw allow 'Nginx FULL' | |
sudo nginx -t | |
sudo systemctl reload nginx | |
sudo mkdir -p /var/www/domain/html | |
sudo chown -R $USER:$USER /var/www/domain/html | |
sudo chmod -R 755 /var/www/domain | |
nano /var/www/domain/html/index.html | |
<html> | |
<head> | |
<title>Welcome to your_domain!</title> | |
</head> | |
<body> | |
<h1>Success! The your_domain server block is working!</h1> | |
</body> | |
</html> | |
sudo nano /etc/nginx/sites-available/domain | |
######################################################################### | |
server { | |
server_name domain www.domain api.domain; | |
location / { | |
proxy_pass http://localhost:4000; | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection "upgrade"; | |
proxy_set_header Host $host; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Forwarded-Proto $scheme; | |
proxy_set_header X-Forwarded-Host $host; | |
proxy_set_header X-Forwarded-Port $server_port; | |
} | |
} | |
######################################################################### | |
server { | |
root /home/user/repo | |
index index.html index.htm index.nginx-debian.html; | |
server_name your_domain; | |
location / { | |
try_files $uri $uri/ =404; | |
} | |
} | |
######################################################################### | |
sudo ln -s /etc/nginx/sites-available/domain /etc/nginx/sites-enabled/ | |
sudo nano /etc/nginx/nginx.conf | |
#uncomment server_names_hash_bucket_size 64; | |
########################CERTBOT SETUP######################## | |
sudo certbot --nginx -d domain -d www.domain | |
sudo systemctl status certbot.timer | |
sudo certbot renew --dry-run | |
########################CERTBOT REMOVE########################## | |
sudo rm /etc/nginx/sites-available/domain | |
sudo rm /etc/nginx/sites-enabled/domain | |
# Check whether nginx has valid configurations and then reload the service | |
sudo nginx -t | |
sudo service nginx restart | |
sudo certbot certificates | |
# Remove certificates for a given domain | |
sudo certbot delete --cert-name domain | |
#####################SSH KEY########################## | |
ssh-keygen -t ed25519 -C "babierichie@hotmail.com" | |
eval "$(ssh-agent -s)" | |
ssh-add ~/.ssh/id_ed25519 | |
cat ssh-add ~/.ssh/id_ed25519.pub | |
#####################Python########################### | |
pip install virtualenv | |
virtualenv --python=python3 venv | |
source venv/bin/activate | |
deactivate venv | |
#####################PM2 SERVE############################ | |
pm2 start log-rename.js --no-autorestart --cron "59 23 * * *" --name "Log rename" | |
pm2 start create-temp-asset.js --no-autorestart --cron "*/2 * * * *" --name "Assets queue" | |
pm2 start npm --name "app" -- run start:staging | |
pm2 serve myReactApp/ 3000 --name "my-react-app" --spa | |
pm2 start yarn --name api -- start | |
pm2 start yarn --name "nextjs" --interpreter bash -- start | |
pm2 serve . 4000 --spa --name akcyberdolphin | |
pm2 start yarn --name supershibas -- start next | |
pm2 start server.js --name supershibas_api | |
pm2 start whalebot.py --interpreter=python3 | |
pm2 start apecoin.py --interpreter=python3 --no-autorestart --cron "*/60 * * * *" --name "Apecoin check" | |
pm2 save | |
pm2 startup | |
pm2 restart 8 -n "GuildPortal" -- run start | |
pm2 restart 8 -n "GuildPortal" --cron 0 | |
pm2 start npm --name "Landing" -- run start | |
pm2 start npm --name "Portal" -- run start:staging | |
pm2 start npm --name "API" -- run start:staging | |
pm2 start create-temp-asset.js --no-autorestart --cron "*/2 * * * *" --name "AssetsQueue" | |
pm2 start get_price.js --no-autorestart --cron "*/10 * * * *" --name "GetPrice" | |
pm2 start npm --name "Event" -- run start:staging | |
pm2 start log-rename.js --no-autorestart --cron "59 23 * * *" --name "LogRename" | |
pm2 start app.py --interpreter=python3.9 --name "QuestCodes" | |
pm2 start npm --name "GuildPortal" -- run start | |
pm2 start websocket.js --name "MailsacForwarder" | |
pm2 start app.py --interpreter=python3.9 --name "TempmailChecker" | |
pm2 start auto-cancel-order.js --no-autorestart --cron "*/6 * * * *" --name "CancelExpireOrder" | |
pm2 start check-order.js --no-autorestart --cron "*/2 * * * *" --name "ListingDelay" | |
pm2 start cron-mp-snapshot-1.js --no-autorestart --cron "0 */1 * * *" --name "1H_Snapshot" | |
pm2 start cron-mp-snapshot-24.js --no-autorestart --cron "0 0 */1 * *" --name "24H_Snapshot" | |
######################################### | |
server { | |
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 domain www.domain; # managed by Certbot | |
location ^~ /assets/ { | |
gzip_static on; | |
expires 12h; | |
add_header Cache-Control public; | |
} | |
location / { | |
proxy_http_version 1.1; | |
proxy_cache_bypass $http_upgrade; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection 'upgrade'; | |
proxy_set_header Host $host; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Forwarded-Proto $scheme; | |
proxy_pass http://localhost:4000; | |
} | |
listen [::]:443 ssl; # managed by Certbot | |
listen 443 ssl; # managed by Certbot | |
ssl_certificate /etc/letsencrypt/live/domain/fullchain.pem; # managed by Certbot | |
ssl_certificate_key /etc/letsencrypt/live/domain/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 { | |
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 api.domain; # managed by Certbot | |
location ^~ /assets/ { | |
gzip_static on; | |
expires 12h; | |
add_header Cache-Control public; | |
} | |
location / { | |
proxy_http_version 1.1; | |
proxy_cache_bypass $http_upgrade; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection 'upgrade'; | |
proxy_set_header Host $host; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Forwarded-Proto $scheme; | |
proxy_pass http://localhost:4040; | |
} | |
listen [::]:443 ssl; # managed by Certbot | |
listen 443 ssl; # managed by Certbot | |
ssl_certificate /etc/letsencrypt/live/domain/fullchain.pem; # managed by Certbot | |
ssl_certificate_key /etc/letsencrypt/live/domain/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 = api.domain) { | |
return 301 https://$host$request_uri; | |
} # managed by Certbot | |
if ($host = www.domain) { | |
return 301 https://$host$request_uri; | |
} # managed by Certbot | |
if ($host = domain) { | |
return 301 https://$host$request_uri; | |
} # managed by Certbot | |
listen 80 ; | |
listen [::]:80 ; | |
server_name api.domain domain www.domain; | |
return 404; # managed by Certbot | |
} | |
==================================== | |
server { | |
root /home/admin/club-de-beaute/dist; | |
server_name clubdebeaute.io www.clubdebeaute.io; | |
location / { | |
try_files $uri $uri/ @router; | |
index index.html index.htm; | |
} | |
location @router { | |
rewrite ^.*$ /index.html last; | |
} | |
listen [::]:443 ssl ipv6only=on; # managed by Certbot | |
listen 443 ssl; # managed by Certbot | |
ssl_certificate /etc/letsencrypt/live/clubdebeaute.io/fullchain.pem; # managed by Certbot | |
ssl_certificate_key /etc/letsencrypt/live/clubdebeaute.io/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 { | |
server_name verify.clubdebeaute.io; | |
location / { | |
proxy_http_version 1.1; | |
proxy_cache_bypass $http_upgrade; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection 'upgrade'; | |
proxy_set_header Host $host; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Forwarded-Proto $scheme; | |
proxy_pass http://localhost:4000; | |
} | |
listen [::]:443 ssl; # managed by Certbot | |
listen 443 ssl; # managed by Certbot | |
ssl_certificate /etc/letsencrypt/live/clubdebeaute.io/fullchain.pem; # managed by Certbot | |
ssl_certificate_key /etc/letsencrypt/live/clubdebeaute.io/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 | |
} | |
枸杞子15克、桂圓9克、紅棗5克、蓮子5克泡水喝 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment