0

I am new in web development and trying to load my website on ubuntu web server for the first time. The website is developed with Flask at backend. I loaded the website on local server and it's loading well on 127.0.0.1:5000/.

I purchased a droplet on digitalocean.com and uploaded it on ubuntu webserver. It is loading well on 157.245.243.108:5000/. I purchased domain name from godaddy.com.

The problem is that website is loading well with ip address (157.245.243.108) along with 5000 port. The godaddy DNS does not accept port value. It only asks for ip address. When I upload ip address only (without port) it only loads apache2 server page.

The question is: How to load website to IP address only without port number? I am willing to share my code if required.

davidism
  • 121,510
  • 29
  • 395
  • 339
Zeeshan Ali
  • 49
  • 1
  • 7
  • Add a proxy pass for your flask app running on 5000 to 80(HTTP)/443(https) in apache2 https://www.digitalocean.com/community/tutorials/how-to-use-apache-http-server-as-reverse-proxy-using-mod_proxy-extension – Himanshu Bansal Jun 28 '21 at 05:59

1 Answers1

0

you must add config ServerName and ProxyPass on your apache config, maybe this example can help you:

<VirtualHost *:80> 
     ServerAdmin admin@your-domain.com
     ServerName your-domain.com
     ServerAlias www.your-domain.com

     ProxyPreserveHost On
     ProxyPass / http://127.0.0.1:5000/
     ProxyPassReverse / http://127.0.0.1:5000/
</VirtualHost>

detail :

  • ServerAdmin : directive to an email that the site administrator can receive emails
  • ServerName : This will most likely be your domain
  • ServerAlias : This is useful for matching hosts you defined, like www
  • ProxyPreserveHost : makes Apache pass the original Host header to the backend server
  • ProxyPass : it specifies that everything under the root URL (/) should be mapped to the backend server at the given address
  • ProxyPassReverse : should have the same configuration as ProxyPass. . It tells Apache to modify the response headers from backend server. This makes sure that if the backend server returns a location redirect header, the client’s browser will be redirected to the proxy address and not the backend server address, which would not work as intended.

reference from :

Eki Saputra
  • 177
  • 1
  • 7