Nginx Reverse Proxy
Ubuntu 22 Nginx Reverse Proxy Commands
1 sudo apt-get update -y 2 sudo apt install curl 3 curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - 4 sudo apt install nodejs 5 node -v 6 npm -v 7 sudo apt update 8 sudo apt install nginx 9 sudo systemctl start nginx 10 sudo systemctl status nginx 11 sudo systemctl enable nginx 12 sudo mv /etc/nginx/sites-available/default /etc/nginx/sites-available/default.orginal 13 sudo vi /etc/nginx/sites-available/default 14 sudo vi /var/www/html/index.html 15 pwd 16 mkdir -p payment/public 17 cd payment/ 18 cd public/ 19 vi payment.html 20 cd .. 21 vi server.js 22 sudo chmod -R 755 /var/www/html/ 23 sudo nginx -t 24 sudo service nginx restart 25 sudo service nginx status 26 node server.js
sudo vi /etc/nginx/sites-available/default
server { listen 80; listen [::]:80; server_name pay.kishoreweb.com; root /var/www/html; index index.html index.htm index.nginx-debian.html; location /payment { proxy_pass http://localhost:3000; 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_cache_bypass $http_upgrade; proxy_read_timeout 300; proxy_connect_timeout 300; proxy_send_timeout 300; } location / { try_files $uri $uri/ =404; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } }create index.html file in /var/www/html/
My E-Commerce Site My E-Commerce Site
payment.html
Payment Page Payment Page
server.js
https://stackoverflow.com/questions/65582660/using-different-aws-credentials-in-bitbucket-pipeline -->
var http = require('http'); var fs = require('fs'); var path = require('path'); http.createServer(function (req, res) { if (req.url === '/payment') { fs.readFile(path.join(__dirname, 'public', 'payment.html'), function(err, data) { if (err) { res.writeHead(500, {'Content-Type': 'text/plain'}); res.end('500 - Internal Server Error'); } else { res.writeHead(200, {'Content-Type': 'text/html'}); res.end(data); } }); } else { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('SHIVAM welcomes you... here after all is good.'); } }).listen(3000, "127.0.0.1"); console.log('Server running at http://127.0.0.1:3000/');