By th3pl4gu33
I have an Ubuntu-20.04 server, and I am using this to deploy multiple docker containers and using reverse proxies to host them on Nginx.
I have 2 domains linked to my server (Single Public IP). Let’s name them domain1.com and domain2.com
Now I have 2 service running on docker, Postgres (port 5432) and MySQL (port 3306)
I set up reverse proxies to translate domain1.com to localhost:5432 and domain2.com to localhost:3306:
server {
listen 80;
server_name domain1.com;
location / {
proxy_pass http://localhost:5432;
}
}
server {
listen 80;
server_name domain2.com;
location / {
proxy_pass http://localhost:3306;
}
}
The thing that is bothering me here is that if I try to access domain1.com:3306, the connection works which I don’t want.
I want each domain to be accessible by the service assigned to them only.
For example a telnet to domain1.com:5432 should work but a telnet to domain1.com:3306 should fail. (I hope this makes sense here)
Can someone please help me achieve this?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi @th3pl4gu33,
hmm, are those ports available to the public? My first thought, is to actually deny both these ports publically and make them accessible only internally.
If the above doesn’t work or if you want to make even a safer option, maybe you can create redirection rules. When the mentioned ports are accessed to redirect requests to your main websites. I think this one should be pretty straightforward as the first suggestion.
Regards, KFSys
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.