Jump to content

Website Hosting on different port.

Khoomn

So I currently have a VPS which i run some things on and one of them is a python program that hosts a website with flask. it takes up the default port of 80. I want to host my main website I have with apache2 on a different port since they both cant be running the same port. I remember trying to change the port on apache2 and it never worked and I dont remember why. Is there a way to host a website on apache with a different port such as 8080 or something like that so when you goto mysite.com it will automatically load the 8080 port instead? I know there is ports.conf in the settings but like i said, i forget why it didnt work.

Link to comment
Share on other sites

Link to post
Share on other sites

You're looking for Apache Virtual Hosts. You can read the Virtual Host documentation here, with an excellent setup guide available from DigitalOcean here.

Make sure to quote me or use @PorkishPig to notify me that you replied!

 

 

Desktop

CPU - Ryzen 9 3900X | Cooler - Noctua NH-D15 | Motherboard - ASUS TUF X570-PLUS RAM - Corsair Vengeance LPX DDR4-3200 32GB Case - Meshify C

GPU - RTX 3080 FE PSU - Straight Power 11 850W Platinum Storage - 980 PRO 1TB, 960 EVO 500GB, S31 1TB, MX500 500GB | OS - Windows 11 Pro

 

Homelab

CPU - Core i5-11400 | Cooler - Noctua NH-U12S | Motherboard - ASRock Z590M-ITX RAM - G.Skill Ripjaws V DDR4-3600 32GB (2x16)  | Case - Node 304

PSU - EVGA B3 650W | Storage - 860 EVO 256GB, Sabrent Rocket 4.0 1TB, WD Red 4TB (x6 in RAIDZ1 w/ LSI 9207-8i) | OS - TrueNAS Scale (Debian)

Link to comment
Share on other sites

Link to post
Share on other sites

Your browser will always connect to port 80 for HTTP and port 443 for HTTPS, since those are the well known ports for these protocols. This is not something you can override on the server side.

 

If you want your browser to connect to a different port, you need to manually append that port to the url, e.g. "http://domain.com:8080". You could configure an automatic redirect on the server, but that will only happen once the client has made the initial connection to port 80. So you'd still need something to listen on port 80 and redirect accordingly.

 

The proper way to do this is to use subdomains and virtual host, so you can do something like http://domain.com and http://python.domain.com. Both of them will listen on port 80 on the same server, and Apache will take care of routing that to the correct application.

 

You could also consider using nginx, which you may find easier to configure:

https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-server-blocks-virtual-hosts-on-ubuntu-16-04

Remember to either quote or @mention others, so they are notified of your reply

Link to comment
Share on other sites

Link to post
Share on other sites

You should set up a subdomain ex flask.yourdomain.com  or whatever, and run that python site using the subdomain

 

Add the subdomain in the dns settings of your domain, then maybe configure vhosts on apache or nginx.

 

Use your regular domain on port 80, the website that everyone will see.

 

 

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×