First of all, disable both services on your machine. then change their ports into something unusual and restart them, for example:
Please remember to open them on 127.0.0.1 ! you shouldn't open them on your network interface.
Install nginx as the most used Reverse Proxy. Depends on your distribution you can install it with one of these commands:
For Debian based distributions:
$ sudo apt install nginx
For Arch based distributions:
$ sudo pacman -S nginx
Completely depends on your distro again, this package could have its own files hierarchical. so I will give you just nginx.conf as the main config file. Just remember to copy original config file with any name you prefer, something like nginx.conf.origin
$ sudo cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.origin
Now, open /etc/nginx/nginx.conf, remove existing configs and copy these configurations inside it:
user nginx;
worker_processes 1;
events {
worker_connections 1024;
}
http {
keepalive_timeout 15;
server {
listen 80 default_server;
server_name example.com;
location /mynodejs {
proxy_pass http://127.0.0.1:6822;
}
location /bugzilla {
proxy_pass http://127.0.0.1:6821;
}
}
}
Notice: Please consider that I wrote this config file with my mind, and because of that you probably will face with an error when you want to run nginx. If so, please write a comment here, so I will test it.
Now, Just restart your nginx! You will get what you want.