Hello, how can i point several subdomains to ip:port, for example api.domain.com -> 22.333.33.222:3000 app.domain.com -> 22.333.33.222:3001
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!
Accepted Answer
Hi @klapovsciuk,
You can redirect your domain to a certain port. This depends on the WebService you are using -Nginx/Apache. If you are using Nginx, you’ll need to do add a server block to your Nginx’s website config. This can be achieved by using the bellow
location /{
proxy_pass http://127.0.0.1:9000/;
}
Having said that, you’ll need to add it to your subdomain’s Nginx server block/config. If you are unsure how you can do that, I’ll recommend checking out he following article:
If you are using Apache, you have two options, the first one is to add a redirection rule in your website’s .htaccess and the second one would be to do it directly in the Apache’s Vhost file. I like using the first option. In your .htaccess file, you can add the following rule
RewriteEngine on
# redirect to 3000 if current port is not 3000 and "some-prefix/" is matched
RewriteRule ^/(.*[^/])/?$ http://www.mysite.com:3000/$1/ [R=301,L]
If you want to use Apache’s Vhost file, I’ll recommend going through the following tutorial :
https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-16-04
Regards, KDSys
Hi there @klapovsciuk,
What you can do is:
api.domain.com -> 22.333.33.222
app.domain.com -> 22.333.33.222
Hope that this helps! Regards, Bobby
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.