By tasmcan
Hi there, I’m newbie in web and DNS things. I have a Ubuntu droplet. I created 2 LXC which they gives me web services. I entered nat-pat configuration for them. If you enter http://ipaddress:2082 goes lxc1 http://ipaddress:2083 goes lxc2
abc.com and def.com are my domains . I want to register these domains to my lxcs. Is it possible ? If yes, how ?
abc.com:2082 and :2083 works well now
Regards
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!
In order to access a site via the bare domain without a port number in the URL, the service must be listening on port 80 (for HTTP) or 443 (for HTTPS). Only one service can be listen to a port at a time. So in order to do what you want, you’ll need to use a reverse proxy of some sort. Nginx is a good fit for this. Let it listen on port 80 and then direct the request to the appropriate service based on the domain name. Here’s a really basic example:
upstream app_server_one {
server 127.0.0.1:2082 fail_timeout=0;
}
upstream app_server_two {
server 127.0.0.1:2083 fail_timeout=0;
}
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
server_name abc.com;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://app_server;
}
}
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
server_name def.com;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://app_server_two;
}
}
Note that setting the server_name directive is important here.
For more info on Nginx, check out:
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.