Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm developing a mobile web application using Django. Currently I can start the Django development server like this:

python ./manage.py runserver <my-ip>:8000

When I do that, I'll get a popup window on my Mac that says,

Do you want the application "python" to accept incoming network connections?

If I click the Allow button and then enter the URI ":8000" I can access the website from my cell phone.

However, their are times that I'd like view plain HTML pages on my phone as well. To that end, I've created an Apache virtual host call "localdev" that is mapped to my /www directory:

# /etc/apache2/httpd.conf
...
DocumentRoot "/www"
...
<Directory "/www">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
...
Include /private/etc/apache2/extra/httpd-vhosts.conf

# /etc/apache2/extra/httpd-vhosts.conf
NameVirtualHost *:80
<VirtualHost *:80>
    DocumentRoot "/www"
    ServerName localdev
    ErrorLog "/private/var/log/apache2/localdev_error_log"
    CustomLog "/private/var/log/apache2/localdev_access_log" common
    <Directory "/www"> 
        DirectoryIndex index.html 
    </Directory>
</VirtualHost>

If I have a website in /www/mysite, I can access it on my Mac using this URI:

http://localdev/mysite/index.html

However, if I try to access that virtualhost site on my phone with this URI:

<my-ip>/mysite/index.html

... I get this message:

Forbidden
You don't have permission to access /mysite/index.html on this server

I have two questions, the first one being more important:

  1. How can I access this site from my phone? This appears to be a pretty common Apache error message that can be caused by any number of things. I've read many articles about it but haven't been able to resolve the problem. What am I doing wrong? Since I can access the site via my computer browser but not from my phone, I'm thinking perhaps it's an OS X firewall issue.

  2. Is there some way I can configure my OS X (Mavericks) firewall so that when I start the Django development webserver, my computer will automatically allow incoming connections and I won't get the pop-up window I described above? I've gone into System Preferences > Security & Privacy > Firewall Options and selected "Allow incoming connections" from the three "python" connections that are shown but I'm still getting the popup window.

share|improve this question
    
Try moving the Order allow, deny and Allow from all in the Directory block of the Virtualhost. –  André Daniel Jun 10 at 15:14
    
Did you mean "Try _re_moving..."? Thanks. –  Robert Jun 10 at 15:17
    
I mean put the access control directives in the VirtualHost's Directory block rather than in the Directory block at the beginning of your httpd.conf. –  André Daniel Jun 10 at 15:20
    
The easiest approach is to put your computer and your phone to same WLAN. The do python runserver 0.0.0.0:8000 (binds all IPs) and use your computer WLAN IP to access the site in the phone e.g. http://192.168.1.2:8000. –  Mikko Ohtamaa Jun 11 at 11:18
    
Andre, you're suggestion that I move the access control block solved the first problem of accessing the virtualhost from my cell phone. Thanks! Mikko, your solution worked as well. I still can't seem to get rid of that Python popup but I can live with that for now. –  Robert Jun 12 at 3:18

1 Answer 1

Are you actually including the file you have your virtual hosts defined in? From your question:

Include /private/etc/apache2/extra/httpd-vhosts.conf

vs

# /etc/apaches/extra/httpd-vhosts.conf

The file paths are different, making it appear you're not actually including the file you have your virtual host definitions in.

share|improve this answer
    
That was a typo. I meant "apache2", not "apaches". I've corrected it in my question. –  Robert Jun 10 at 17:40
    
You still have /private/ at the start of your include, and not in the file name portion. Are you sure it's correctly pulling in the virtual host? Do you see it in your apachectl -S output? –  Christopher Karel Jun 10 at 18:01
    
On Mac OS X, /etc is a symlink to /private/etc. –  Robert Jun 12 at 2:46
    
My bad. I clearly don't know OSX. –  Christopher Karel Jun 12 at 14:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.