Question: I have a Django applciation running on Apache with mod\_wsgi, but I would like to create a development server on the same machine.

I can reach my website by <http://IP_ADD> and I would like to reach the development server from <http://IP_ADD:8080> or another port.

But as you notice, I would like to prevent accessing to 8080 port from users who do not enter predetermined username/password.

How can I achive such protection? I may allow only certain IP address but it is not a solution.

Another question is also about the chosen port. I hace choice 8080 port but I will also setup issue tracking system, SVN etc. and I am not sure which ports should I open for them.

Thank you

Answer: 
For each of the sites you want to host, you could create a separate Apache site with a VirtualHost file along the following lines:

```
<VirtualHost *:8080>
  ServerName www.example.com:8080    // Your name (if available)
  ServerAlias 12.23.34.45            // Your IP
  DocumentRoot /var/www/mydjangoapp  // Your folder

  <Directory />
    Order deny,allow
    Deny from all
    Allow from 127
    AuthName "Restricted area"
    AuthType Basic
    AuthUserFile /etc/apache2/users_mydjangoapp  // Allowed users file
    require valid-user
  </Directory>

```

The userfile itself can be generated using Apache's [authentication system](http://www.apacheweek.com/features/userauth). For each site, you could add a seperate user file to contain the access for that part of your system. For IP based access, just add lines like `Allow from 123.123.123.123` below the `Allow from 127` line.

Finally, additional sites can be created by creating more of these Apache sites (see for example [here](http://www.debian-administration.org/articles/412) for more details). Just adapt the port (`8080` in my example) to the one you want to host the additional sites under.
you can add basic authentication 
<http://djangosnippets.org/snippets/1304/>