I learned about Nginx yesterday and to be more accurate I learned for the first time all the topics covered on the following urls:
- Initial Server setup with ubuntu 16.04
- How to install and secure mongodb on ubuntu 16.04
- How to add swap space on ubuntu 16.04
- How to backup restore and migrate a mongodb database on ubuntu
- How to install Nginx on ubuntu 16.04
- How to secure nginx with let's encrypt on ubuntu 16.04
- How to install node js on ubuntu 16.04
- How to setup a node js application for production on ubuntu 16.04
But I'm still here...stuck,
Where I am
I'm editing this Nginx config file: /etc/nginx/sites-available/default
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
server_name mysite.mydomain.com;
ssl_dhparam /etc/ssl/certs/dhparam.pem;
location / {
proxy_pass http://localhost:8080;
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; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/mysite.mydomain.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/mysite.mydomain.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
}
My Goal
- To have two nodejs http(s??) servers listening on 2 local ports
- Reverse-proxy them to two https ports
- Profit
So to transform this:
To this
https://mysite.domain.com/ & https://mysite.domain.com:1337/
Basically I'm trying to setup a parse server alongside with a node webapp and I don't want the paths to collide so I want them on different public ports.
Sample node webapp server:
const app = express();
app.use(compression());
app.use(express.static(path.resolve(__dirname, '../dist')));
app.get('*', function(req, res) {
res.sendFile(path.resolve(__dirname, '../dist/index.html'));
});
app.listen(8181);
Thanks, in advance.