Score:0

Apache tag for couple of options

in flag

I want to set couple of Location tags in my Apache config. For instance: /image, /file, /audio and to pass it to localhost:port/path. Right now I'm using this for /image:

 <Location /image>
        RewriteEngine  on
        Options +MultiViews +FollowSymLinks
        AllowOverride All
        ProxyPreserveHost On
        ProxyPass "http://localhost:PORT/image"
        ProxyPassReverse "http://localhost:PORT/image"
    </Location>

Do I have to write this piece of code for every param? Or there is any shortcut for it?

Thanks!

Score:0
cn flag
Bob
<Location /image>
   RewriteEngine  on
   Options +MultiViews +FollowSymLinks
   AllowOverride All
   ProxyPreserveHost On
   ProxyPass "http://localhost:PORT/image"
   ProxyPassReverse "http://localhost:PORT/image"
</Location>

Do I have to write this piece of code for every param?

No. The RewriteEngine directive doesn't do anything there and neither the Options nor the AllowOverride directives make any sense when you don't map to resources on the local file system. Those options are controlled and need to be set by the "remote" webserver that you are forwarding the requests to with the ProxyPass directive.

Since those directives are useless, then you don't need the Location bracket either to set them and can use the inline ProxyPass syntax that is recommended anyway.

That reduces your syntax to only the necessary lines:

ProxyPreserveHost On

ProxyPass "/image" "http://localhost:PORT/image"
ProxyPassReverse "/image" "http://localhost:PORT/image"

ProxyPass "/file" "http://localhost:PORT/file"
ProxyPassReverse "/file" "http://localhost:PORT/file"

Apache httpd does offer the Include directive to maintain a single configuration snippet with settings that you want to include verbatim in different places, VirtualHost, Location, Directory blocks without copying the same lines time after time.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.