0

I'm connected to the LAN in my university with an ip address of 172.16.123.12. I'm trying to deploy a flask application on an apache server so that the entire campus can see the website. I've successfully deployed the app using mod_wsgi but I cant get to work on the LAN. It's working fine on localhost/flask but I can't myself access the site on http://127.0.1.1/flask or http://172.16.123.12/flask but the "It works" apache page is accessible from both http://127.0.1.1 and http://172.16.123.12

Here is my virtualhosts conf for the flask site -

<VirtualHost *:80>
    ServerName localhost

    WSGIDaemonProcess flask_test threads=5
    WSGIScriptAlias /flask /var/www/flask_test/flask.wsgi
    ErrorLog "/var/www/flask_test/error.log"
    CustomLog "/var/www/flask_test/access.log" combined

    <Directory /var/www/flask_test>
        WSGIProcessGroup flask_test
        WSGIApplicationGroup %{GLOBAL}
        Order deny,allow
        Allow from all
    </Directory>
</VirtualHost>

Hosts file:

127.0.0.1 localhost
127.0.1.1 Linux

I tried changing the ServerName to my ipaddress as well but to no avail. Can someone please let me know where I am going wrong? Thanks a ton!

Output from apapch2ctl -S

/usr/sbin/apache2ctl: 87: ulimit: error setting limit (Operation not permitted)
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80                   is a NameVirtualHost
         default server 127.0.1.1 (/etc/apache2/sites-enabled/000-default:1)
         port 80 namevhost 127.0.1.1 (/etc/apache2/sites-enabled/000-default:1)
         port 80 namevhost Linux (/etc/apache2/sites-enabled/flasktest:1)
Syntax OK
1
  • Can you provide the output from apache2ctl -S or apachectl -S, as the case may be? Aug 30, 2012 at 4:45

1 Answer 1

2

ServerName localhost means that your app can be accessible only when requesting via the localhost domain.

Delete the ServerName line and move your config to the outside of the VirtualHost section, then try again.

  • /etc/httpd/conf.d/flask.conf (Red Hat based)
  • /etc/apache2/conf.d/flask.conf (Debian based)

    WSGIDaemonProcess flask_test threads=5
    WSGIScriptAlias /flask /var/www/flask_test/flask.wsgi
    
    <Directory /var/www/flask_test>
        WSGIProcessGroup flask_test
        WSGIApplicationGroup %{GLOBAL}
        Order deny,allow
        Allow from all
    </Directory>
    
3
  • This works perfectly! Thanks a ton! Tutorials around the web suggested to use a virtualhost configuration. When should use a virtualhost config and when should I add a conf file in conf.d? Will this method work if I do this on the production server as well? Thanks a ton!
    – Prakhar
    Aug 30, 2012 at 4:59
  • You can use virtualhost config if your servername can be resolvable in LAN. For e.g: setup a local DNS, go to 172.16.123.x machine, do a nslookup your.domain.com will resolve to the 172.16.123.12. Do you have any domain maps to your production server's IP?
    – quanta
    Aug 30, 2012 at 5:18
  • nslookup <production server ip> returns none. So I'm guessing I need to proceed the same way there also.
    – Prakhar
    Aug 30, 2012 at 5:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .