59
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/...
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;
...
8
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 ...
8
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 ...
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:
...
6
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....
6
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) ...
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 ...
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 ...
5
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 ...
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 ...
5
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>
...
5
votes
How to prevent "host header injection vulnerability" in Nginx proxy server
The "host header injection vulnerability" means that your server is accepting any Host header even if it is not a valid hostname for any of your web sites. In your case you have configured a ...
5
votes
Unexpected 301 redirects from Nginx when behind Nginx reverse proxy
A solution, and possibly the solution, came after multiple hard hours of trying to understand the problem and exact behavior of Nginx's redirection mechanism. The solution was rather simple really:
...
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. ...
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 ...
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.
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 ...
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 ...
4
votes
Accepted
How to Set Regular Expression for Nginx Location Block and Proxy Pass?
This answer credit to @Richard Smith;
I am change the config become:
location ~ ^/web/api/v1/([A-Za-z]+)$ {
proxy_pass http://127.0.0.1:5000/$1;
}
localhost become 127.0.0.1
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 ...
4
votes
Accepted
Cockpit via NGINX - settings make other services not reachable
What's missing here?
The problem occurs not on all devices. Some show up that "This connection is not secure." for redmine and gitlab. But cockpit does not. The solution to the riddle is now,...
3
votes
Accepted
Nginx not preserving domain name for wordpress proxy_pass
The problem definitely isn't nginx: your application is rewriting client accesses to the hostname it knows of. Look for nginx logs, I'ld bet there's a few 30x-code logs, redirecting you somehow, ...
...
3
votes
Duplicate max-age header
Use Header "set" instead of Header "add" if you don't want accidental duplicates due to backend sending the same header.
3
votes
Accepted
Nginx can not redirect HTTP to HTTPS in the proxy mode
I would turn on debug logs at nginx and trace what actually goes on when you try accessing your page using http.
I also wouldn't recommend using an IF-statement inside of nginx for what you are ...
3
votes
Accepted
nginx reverse proxy with query parameter modification
So, what ended up working was changing
if ($args ~* (.*)(next_page=http%3A)(.*)) {
set $args $1next_page=https%3A$3;
rewrite ^(.*)$ $1;
}
proxy_pass http://127.0.0.1:80;
proxy_redirect http:/...
3
votes
Configure Nginx as reverse proxy with upstream SSL using server_name
Try adding this in your server config:
proxy_ssl_verify_depth 2;
This sets the verification depth in the proxied HTTPS server certificates chain.
source : nginx_http_proxy_module
3
votes
Accepted
Nginx proxy cookies not set
Finally solved this, the problem was that the main.domain1.com was using SSL while the other domains weren't, I tried disabling SSL on the main domain and it worked, the other domains finally had ...
3
votes
Accepted
NGINX proxy_pass setup fails when adding a location for expiring file types
For example:
map $uri $expires {
default off;
~\.(jpg|jpeg|png|gif|ico|css|js|pdf)$ 7d;
}
server {
...
location / {
expires $expires;
try_files $uri $uri/ /index.php?$...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
proxypass × 586nginx × 327
reverse-proxy × 173
apache-2.4 × 112
apache-2.2 × 107
proxy × 58
mod-proxy × 47
apache2 × 35
rewrite × 30
redirect × 29
ssl × 27
virtualhost × 27
mod-rewrite × 19
linux × 16
tomcat × 16
ubuntu × 14
node.js × 13
docker × 12
wordpress × 12
httpd × 12
nginx-reverse-proxy × 11
https × 10
subdomain × 10
regex × 10
http × 9