0

I have a Python/CherryPy program running on port 7000. It handles it's own webserver, so I've used an Apache reverse proxy so that I can access it with mydomain.org. This works; the config is below.

I would also like Apache to serve (with Index) any files in directory /media by accessing mydomain.org/files. The purpose being to plug a USB drive into the server, it automatically gets mounted on /media/usb and I can give someone the link.

<Location />
     AuthType Basic
     AuthName "Secure"
     AuthBasicProvider file
     AuthUserFile /etc/apache2/auth
     Require valid-user
     Allow from 192.168.1.1/24
     Satisfy Any
     ProxyPass http://localhost:7000/
     ProxyPassReverse http://localhost:7000/
</Location>

I'm new to Apache so could easily be confused or haven't given enough information or haven't found the right search terms. If so, please let me know .

1 Answer 1

1

Make sure that the directory /media does have a correct configuration (you need mod_autoindex module to be loaded)

<Directory /media>
    Allow from all
    Options +Indexes
</Directory>

Set the alias to point to /media

Alias /files /media

Make sure to not proxy the /files URL space by using ! in the directive

ProxyPass /files !

The complete configuration for a particular virtual host can be following

<Directory /media>
    Allow from all
    Options +Indexes
</Directory>

Alias /files /media

<Location />
     AuthType Basic
     AuthName "Secure"
     AuthBasicProvider file
     AuthUserFile /etc/apache2/auth
     Require valid-user
     Allow from 192.168.1.1/24
     Satisfy Any
</Location>

ProxyPass /files !
ProxyPass / http://localhost:7000/
ProxyPassReverse / http://localhost:7000/
6
  • Can you explain a little more? My guess is that under <Location /> you are not proxying /files (is that what ! means?) and then allowing access to /media, but where are you linking mydomain.org/files to /media?
    – bkanuka
    Aug 10, 2013 at 15:04
  • I've edited the answer. Yes, exclamation mark makes the URL space to be excluded from proxying. And yes, I've forgot to make a required alias. Was somehow assuming that the document root will be set to "/media" which is an option. Aug 10, 2013 at 15:22
  • Okay thank you! However, I don't think ProxyPass /files ! should be in a Location block: it causes error: ProxyPass|ProxyPassMatch can not have a path when defined in a location.
    – bkanuka
    Aug 10, 2013 at 15:25
  • Furthermore, I have to put ProxyPass /files ! <Directory /media> Allow from all Options +Indexes </Directory> Alias /files /media before the code I have in my question. Can you please add that to your answer (if correct?). Thank you for the help.
    – bkanuka
    Aug 10, 2013 at 15:27
  • Oh yes, right normally you have it outside location and I guess the "ProxyPass localhost:7000" works, because normally outside of location block you would say "ProxyPass / localhost:7000". You may want to do it so you have ProxyPass directives on one place. Aug 10, 2013 at 15:36

You must log in to answer this question.

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