I would like to redirect a subdomain to an URL of a webapp. Something like:
newsub.domain.com >>>> another.domain.com:8080/myWebApp
How can I do it?
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!
Do you want this to be permanent or temporary? There are various ways to do this. You could create an index file in the document root that redirects, setup rewriting of a location in the virtual host depending on what web server you use, etc.
Hi,
To do so, you have 2 solutions :
<?php
header('Location: http://another.domain.com:8080/myWebApp ');
exit;
?>
This solution is not the smartiest one, as it shows an unusual port in the URL for your webapp.
location / {
proxy_pass http://another.domain.com::8080/myWebApp;
proxy_cache cache;
proxy_cache_valid 12h;
expires 12h;
proxy_cache_use_stale error timeout invalid_header updating;
}
I would rather opt for the 2nd solution, as the reverse proxy will conserve newsub.domain.com in the URL for your web users.
Hope this could help,
Regards,
– rustx
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.