Hot answers tagged

35

Looks like you're not loading the mod_proxy_http module (which is needed to proxy to HTTP servers). I don't have Ubuntu 10.04 in front of me, but IIRC it's something like: sudo a2enmod proxy_http


22

Add retry=0 to your ProxyPass lines: ProxyPass / http://127.0.0.1:4711/ retry=0 From the mod_proxy documentation: Connection pool worker retry timeout in seconds. If the connection pool worker to the backend server is in the error state, Apache will not forward any requests to that server until the timeout expires. This enables to shut down the ...


16

I finally fixed this problem after testing several configuration parameters. I tested the solution twice, removing all previous changes. Only one parameter was needed for me to fix it. For the latest versions of httpd and mod_proxy_fcgi you can simply add timeout= to the end of the ProxyPassMatch line, e.g.: ProxyPassMatch ^/(.+\.php.*)$ fcgi://127.0.0.1:...


13

In case someone else runs into this. This is a bug in mod_proxy that can be avoided by putting these lines in your httpd.conf: SetEnv force-proxy-request-1.0 1 SetEnv proxy-nokeepalive 1 https://issues.apache.org/bugzilla/show_bug.cgi?id=37770 For info on what these variables do see the mod_proxy documentation. They have a specific section, Protocol ...


11

My company just did this with several largish Web sites. The basic procedure we followed was: Lower the domain's TTL as much as possible. Do this in advance by at least as much time as the current TTL. Set up the Web site on the new server exactly how you want the "final product" to be Add an aliased name to the site on the new server, such as www2.domain....


11

I solved my issue : If I do: sestatus -b | grep httpd I can see httpd_can_network_connect is off The solution is to type: togglesebool httpd_can_network_connect


11

You exclude paths from mod_proxy with an exclamation mark (!) before your full ProxyPass statement, which your sample is missing - It would look something like ProxyPass /path balancer://backend-cluster1. Therefore, to exclude a path, add: ProxyPass /my/excluded/path ! before ProxyPass /my balancer://backend-cluster1


10

Ok, figured it out, turns out that - obviously - there's no need to specify the proxy for excluded paths. ProxyPass /somedir ! works great


10

This would work: iptables -A INPUT ! -s 127.0.0.1 -p tcp -m tcp --dport 8080 -j DROP


9

I always wrestle with a problem for hours before giving up and posting a question - only to solve my own problem minutes after posting ... For those interested, the solution is not to use ProxyPassReverse, but rather to use the Header directive - it' let's you mess with outbound headers. In this case, I can capture the Location response header and run a ...


9

You can avoid proxying for a specific directory by specifying a ! in place of the proxy target. Since it acts on a directory, move error.html into a subdirectory (we'll say errors), and: <VirtualHost *:80> ServerName servername DocumentRoot /somepath/ ProxyPass /errors ! ProxyPass / http://localhost:8080/someapp/ ProxyPassReverse / http://...


9

mod_proxy marks an unresponsive backend as down when it seems to be down; if no backends are available then it responds with a 503. By default, a down backend will be marked as such for 60 seconds; until that time passes, it won't retry the connection (and replies with an error message to any connecting clients). To have it retry immediately, add retry=0 ...


9

I went ahead and researched this one out. After reading multiple tutorials and the Apache doc, I was able to piece together something substantial, which seems to work well. Using the list above, I put together a set of rules/declaratives which seem to handle compression with the mainstream content types: <Location /> # Insert filter SetOutputFilter ...


8

Both methods forward requests from apache to tomcat. mod_proxy uses the HTTP that we all know an love. mod_jk uses a binary protocol AJP. The main advantages of mod_jk are: AJP is a binary protocol, so is slightly quicker for both ends to deal with and uses slightly less overhead compared to HTTP, but this is minimal. AJP includes information like original ...


8

I'm going to make the assumption that you do accept HTTP connections for the public, but you do a standard HTTP redirect to force them to HTTPS. If this is the case, then you can alter your HTTP directives to not redirect if you are part of the internal network. To do this, you want to use Apache's mod_rewrite and filter on REMOTE_ADDR. Essentially, you ...


8

This is possible with mod_headers, mod_rewrite, and mod_proxy. On the proxy, I assume you have your authentication working and setting REMOTE_USER appropriately. If so, then put the value of REMOTE_USER into a Proxy-User header to the backend like this: RewriteRule .* - [E=PROXY_USER:%{LA-U:REMOTE_USER}] # note mod_rewrite's lookahead option RequestHeader ...


8

This directive lets Apache adjust the URL in the Location, Content-Location and URI headers on HTTP redirect responses. For example, suppose the local server has address http://example.com/; then ProxyPass /mirror/foo/ http://backend.example.com/ ProxyPassReverse /mirror/foo/ http://backend.example.com/ ProxyPassReverseCookieDomain backend.example.com ...


8

I found this solution, I don't know if is the best way, but works for me. Remove the line: ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.2:9126/<path>/$1 Add this in your directive: <Directory /var/www/yoursiste.com> Options -Indexes +FollowSymLinks -ExecCGI +MultiViews AllowOverride All <IfModule mod_proxy_fcgi.c> ...


8

Yes very much possible. For example: <VirtualHost *:80> ServerName yourdomain.tld ServerAlias www.yourdomain.tld *.yourdomain.tld DocumentRoot /path/to/your/website/document/root ProxyPass /images ! ProxyPass /assets ! ProxyPass / http://127.0.0.1:8080/ ProxyPassReverse / http://127.0.0.1:8080/ <Proxy http://localhost:8080/*&...


8

Under Apache 2.2, no - the ProxyPreserveHost directive is only valid in the server config or virtual host contexts; you'd need the different ProxyPass statements to be in different virtual hosts. In Apache 2.4, yes - the directory context has been added for the directive, so you can now do something such as: <Location /to-varnish/> ...


8

We have a similar setup and are using this (of course you need to load before mod_proxy, mod_ssl and mod_proy_http): ProxyRequests Off SSLProxyEngine On <Proxy *> Order deny,allow Allow from all </Proxy> ProxyPass /proxy/ http://thirdparty.com/app/ ProxyPassReverse /proxy/ http://thirdparty.com/app/ <Location /proxy/> ...


7

I refer to this as a "Sorry Server". If you're using Apache 2.2 you can add another host to your LB pool as a hot spare, and when the actual app servers reach capacity your balancer will direct requests to the "Sorry Server" until the application servers become available again. Here's a rough idea: <Proxy balancer://yourapp> BalancerMember http://...


7

It seems there's a difference between stopping and then starting apache and doing a apachectl graceful restarting (i.e. actually stopping and starting as opposed to apachectl restart) as found at this site: This is a bit of a guess, and probably wrong, but does stopping and starting the server rather than restarting (they're different, restarting (...


7

I wanted to point out that although this answer works great for older versions, it breaks under recent versions of Apache 2.4 with error code AH00526. ProxyPass and ProxyPassMatch or <Proxy> and <ProxyMatch> cannot be used together within the same worker name. This used to function just fine, so don't know if that was changed by design or if it's ...


6

Maybe he/she/it was trying to figure out if it was worth a try. It costs them nothing to just send a proxy request to a server and see if it works, so usually they send out these requests indiscriminately. FYI one surefire way to make sure mod_proxy is disabled is to make sure the line LoadModule mod_proxy.so proxy_module is commented out. It should only ...


6

You could use a mod_rewrite using a RewriteMap with a single value: RewriteMap server txt:/path/to/file/map.txt RewriteRule ^/(.*) http://${server:production}/$1 [P,L] Then create /path/to/file/map.txt with this content # To use a different server, change appserver.com # to e.g. maintenance.appserver.com production appserver.com As soon as ...


6

Try %{BALANCER_WORKER_ROUTE}e. There's a few other variables available for checking on the request routing, too; see here.


6

The code for the forum has the /forum/ path hardcoded in the HTML that it's sending to the client, or otherwise defined somewhere in its configuration. If you can change it to /, do so; otherwise, you can work around it in your Apache config: <VirtualHost *:80> ServerName forum.mydomain.com ProxyPass /forum/ http://127.0.0.1:8080/forum/ ...


6

You're going to want to do something like this on Server A: NameVirtualHost * <VirtualHost *> ServerName owncloud.mydomain.com ProxyRequests Off <Proxy *> Order deny,allow Allow from all </Proxy> ProxyPass / http://192.168.0.10:80/ ProxyPassReverse / http://192.168.0.10:80/ <Location /> ...


5

You might try: # cd /etc/apache2/mods-enabled/ # ln -s ../mods-available/proxy.load # ln -s ../mods-available/proxy_http.load



Only top voted, non community-wiki answers of a minimum length are eligible