69
votes
Nginx location regex doesn't work with proxy pass
A small addition to the great answer from Xaviar:
If you happen to be not so well acquainted with nginx, there's an important difference between adding the slash to the end of the proxy_pass ...
Community wiki
51
votes
Accepted
How to handle relative urls correctly with a nginx reverse proxy
The problem is basically that using a proxy_pass directive won't rewrite HTML code and therefor relative URL's to for instance a img src="/assets/image.png" won't magically change to img src="/bbb/...
- 73.5k
42
votes
Accepted
Why am I getting an "Invalid command 'ProxyPass'" error when I start my Apache 2.2 server?
proxy_http module requires proxy, and ProxyPass directive is defined in the latter.
Make sure it's also loaded.
Thanks to Milind Singh
Load the module by running
Run sudo a2enmod proxy_http
- 2,103
32
votes
Nginx location regex doesn't work with proxy pass
It tells you that the URI in the proxy pass directive can't be used in a regex location. This is because nginx can't replace the part of the URI matching the regex in the location block with the one ...
- 12.9k
22
votes
How to remove the path with an nginx proxy_pass
I'd like to address a newer regex-based answer that's been rising in popularity.
location ~ ^/en(/?)(.*)$ { # OOPS!
proxy_pass http://luscious/$2$is_args$args; # OOPS!
}
The solution may seem ...
- 13.4k
10
votes
Accepted
encode URL wihthin URL - apache mod-proxy (ProxyPass)
In the default Apache configuration, the AllowEncodedSlashes directive is set to off. This means that: "...The AllowEncodedSlashes directive allows URLs which contain encoded path separators [...] to ...
- 3,988
9
votes
Accepted
NGINX proxy_pass with URI modification
From nginx's documentation (context : prefixed location)
If the proxy_pass directive is specified with a URI, then when a request is passed to the server, the part of a normalized request URI ...
- 12.9k
8
votes
Accepted
Redirect traffic based on url to different ip address maintaining port and url information
I have established what the problems were with my setup.
1) SELinux was preventing me from connecting upstream. I have now disabled this and will consider setting it up properly later
2) proxy_pass ...
- 251
8
votes
Accepted
Nginx proxy_pass to wordpress docker container
It may help to set some headers so that the upstream knows the correct frontend server name. See this document for more.
For example, I use:
proxy_set_header Host $host;
...
- 12.2k
7
votes
NGINX proxy_pass with URI modification
I know this is an old question but I was looking for this and found another and I belive the easiest solution. While using proxy_pass you can't use uri however you can use it as variable. Like here:
...
- 71
7
votes
Nginx proxy_pass root and specific url only
location / matches any location - if you want to match only /, you should use location = /. See this document for details.
Also, your regular expression location is missing the ~ or ~* operator. But ...
- 12.2k
6
votes
Apache Virtual Hosts .. Redirect .. ProxyPass .. and Alias
This should works:
DocumentRoot /var/www/html
Redirect (!/mm) https://server.org/test/
Alias /mm "/var/opt/mm"
Alias /test/mm "/var/opt/mm"
<Directory "/var/opt/mm">
Options Indexes ...
- 3,043
6
votes
Accepted
nginx upstream not working
When you use proxy_pass without proxy_set_header directives, nginx will use some default headers. Most times it's what you would want or, at least, harmless, but in your case you have to set them ...
- 8,100
6
votes
Accepted
Nginx variable in proxy pass does not work
Those two cases are not the same. If you use a variable, that value will replace the entire URI.
In this case:
location /site {
proxy_pass http://docker-site/site/mobile;
}
the URI /site/foo ...
- 12.2k
6
votes
Accepted
nginx proxy gives 404 not found
Okay, I did some testing. The problem is this line:
proxy_set_header Host $host;
This line has the effect that the http request of the proxy is done using the same hostname as the original request TO ...
- 21.4k
5
votes
Apache Reverse Proxy setting for site having Spring Security
I've been struggling with this same problem for a few days and I might have cracked it. I'm new to Spring Security so don't take this as gospel! Others might object... I'm using Apache 2.4 (on OS X) ...
- 61
5
votes
Redirect traffic based on url to different ip address maintaining port and url information
You want to maintain the port, then you should put it in proxy_pass.
server {
server_name bob.something.com;
listen 41001;
listen 41002;
listen 8080;
location / {
...
- 8,100
5
votes
How to remove the path with an nginx proxy_pass
Accounting to Nginx documents
To pass a request to an HTTP proxied server, the proxy_pass directive is specified inside a location. For example:
location /some/path/ {
proxy_pass http://www....
- 159
5
votes
Accepted
Nginx Proxy Pass SSL Verification
The documentation for proxy_ssl_trusted_certificate states:
Specifies a file with trusted CA certificates in the PEM format used to verify the certificate of the proxied HTTPS server.
Since you're ...
- 240k
5
votes
Accepted
nginx denies all requests to a virtual host . requests are coming from a nginx tcp forwarder
This is happening because your nginx load balancer makes a new TCP connection to your nginx web servers, causing the original client IP address to be lost.
You can solve this using the PROXY protocol. ...
- 240k
4
votes
Nginx proxy pass url from get argument
Try this:
location ~ /proxy/(http://.*) {
resolver 8.8.8.8;
proxy_pass http://$1$is_args$args;
}
No explicit rewriting needed. $is_args will be set to ? if the request line has arguments, or ...
- 211
4
votes
Accepted
Using nginx to proxy multiple instances of sockets.io
I was having the exact problem and I found this simple workaround :
Configure your client socket.io from your js/html file to connect from subdirectory (The default socket.io setting will have your ...
4
votes
Accepted
ProxyPass a WebSocket connection to a UNIX socket
Ok I got it, once you have mod_proxy and mod_proxy_wstunnel enabled you can do this:
ProxyPass /ws/ unix:/path/to/app.sock|ws://example.com/ws/
It works well for me since I only expect to establish ...
- 156
4
votes
Accepted
Nginx proxy: deny all apart from sub-path
Fixed on advice from Richard's comment.
Nginx only matches one location block, so I moved the headers to be defined in the server and set proxy_pass with the appropriate allow,deny on paths to be ...
- 71
4
votes
Accepted
Configuring multiple ProxyPassReverseCookiePath in Apache HTTP
After searching around the solution is to group the directives under a <Location> tag:
<Location /app1>
ProxyPassReverseCookiePath /app /app1
</Location>
<Location /app2>
...
- 191
4
votes
Accepted
nginx set directive not working
The Nginx config itself was indeed correct.
The problem I had was envsubst also replacing the $backend variable with an empty space.
- 218
4
votes
Accepted
Nginx: Forcing upstream server to log proxy server's request id instead of it's own request id
You don't actually want the upstream server to log the request ID in $request_id. Instead you want it to log the contents of an HTTP request header named X-Request-ID.
In that case you should log the ...
- 240k
4
votes
Accepted
XAMPP deny access from specific external IP address
As @MichaelHampton already commented: remove the following settings immediately:
<Proxy *>
order allow,deny
deny from 193.37.XXX.XX
allow from all
</Proxy>
Those are not ...
- 73.5k
4
votes
nginx denies all requests to a virtual host . requests are coming from a nginx tcp forwarder
My approach would be:
Filter in the load balancer using SNI:
Basically: SNI allows the proxy to see the domain name, without terminating TLS. Here is a guide. And here are the nginx docs to combine it ...
- 827
3
votes
Apache ProxyPass worker name too long
An alternate (and in my opinion, more elegant) solution would be to use the RewriteEngine, as is discussed in this Apache bug report https://bz.apache.org/bugzilla/show_bug.cgi?id=53218
# This ...
- 131
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
proxypass × 575nginx × 325
reverse-proxy × 168
apache-2.4 × 107
apache-2.2 × 103
proxy × 57
mod-proxy × 46
apache2 × 32
ssl × 27
redirect × 27
rewrite × 27
virtualhost × 25
mod-rewrite × 18
tomcat × 17
linux × 14
wordpress × 13
httpd × 13
node.js × 13
docker × 12
ubuntu × 11
https × 10
subdomain × 10
regex × 10
nginx-reverse-proxy × 9
web-server × 8