By BLU
Hello, is it possible to run different containers with different Domains?
For example: container 1 has an application with port 123456 running and the container should only reachable on app1.domain.com
and container 2 has the same application (with port 123456) but should only reachable with app2.domain.com
yours sincerely lassdas
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!
You can achieve that by running a reverse proxy server (such as nginx) in front of the applications.
First, install nginx on your droplet that is hosting the containers:
sudo apt-get update
sudo apt-get install nginx
Then, for each application, create a server block:
sudo nano /etc/nginx/sites-available/app1.domain.com
and insert the following into the file (replace app1.domain.com and 2368 as needed):
server {
listen 80;
server_name app1.domain.com;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://127.0.0.1:2368;
}
}
Enable the server block:
sudo ln -s /etc/nginx/sites-available/app1.domain.com /etc/nginx/sites-enabled/
Once you have done that for all applications, restart nginx:
sudo service nginx restart
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.