Sorry, I meant to say that (!-f $request_filename) check IS a terrible way to check the existence of the file, as suggested by the documentation.by mrtn - Nginx Mailing List - English
I need to make sure a file actually exists before proxy_pass-ing the request to an upstream server. I don't serve existing files directly using Nginx because there are some application-specific logic i need to perform on the application server for such requests. I've looked at try_files, but it seems like it will serve the file straightaway once it is found, which is not what I want here. Anothby mrtn - Nginx Mailing List - English
So, I've found out more about my situation. Apparently, limit_conn_zone stuff I'm doing on Nginx applies to HAProxy only which is in front of my Nginx. I guess I have two options: 1. Use HAProxy (instead of Nginx) for request/connection limiting. 2. Limit requests/connections on Nginx based on X-Forwarded-For instead of the IP of HAProxy (which is going to always 127.0.0.1). Which do yby mrtn - Nginx Mailing List - English
In my config, within http section, I have: limit_conn_zone $binary_remote_addr zone=addr:10m; limit_conn addr 3; which I interpret as, setting a memory zone of size 10 megabytes for keeping states of connected IPs and restricting 3 concurrent connections per IP at a time. If the size of the zone is exhausted or the limit per IP is breached, Nginx will return 503 as response.by mrtn - Nginx Mailing List - English
i see. since you mentioned it, is there any way to check for http-only and secure properties of a cookie using nginx? In other words, combined with the original question above, i want to check if a given a cookie is present and it is http-only and secure, otherwise, reject the request with a 404.by mrtn - Nginx Mailing List - English
I have a http-only and secure (ssl) cookie, and I want nginx to check whether this cookie exists in a request, if not, reject it by serving a 404 page. This is just a preliminary check, so I don't care about the actual value in the cookie. So far I've tried this: if ($http_cookie !~* "cookie_name=[.]+") { return 404; } in a location directive, but despite the cookie is contained in thby mrtn - Nginx Mailing List - English
Hello Maxim, Thanks for the suggestion. I checked my Haproxy config again, and this is what I use for adding the 'X-Client-IP' header: option forwardfor header X-Client-IP In addition, if Haproxy is passing header things like 'X-Client_IP', then why is that the requests routed directly to Tornado (not via Nginx) contain the correct header 'X-Client-IP'? It seem like something happens whenby mrtn - Nginx Mailing List - English
Hi, I have a HAProxy running in front of Nginx, and I add 'X-Client-IP' header to reflect the actual IP of the client. If the request is routed directly to the application server (Tornado in my case), this header is present and I can retrieve it with no problem. However, if the request is first routed to Nginx and then to the application server using: proxy_pass http://127.0by mrtn - Nginx Mailing List - English
On a second thought, I think I get what you mean by "internal" directive. It will blocks ALL external requests from browsers, thus my browser request to "/foo/bar/sth" is block immediately and 404 is returned, without doing any proxy_pass. I may need to rethink my design here. Ideally, I want users who request "/foo/bar/sth" in their browsers get served by nginx wby mrtn - Nginx Mailing List - English
Reinis Rozitis Wrote: ------------------------------------------------------- > You are using 'internal' in a wrong way (at least judging from your > configuration excerpts). > > If you read the documentation > http://nginx.org/en/docs/http/ngx_http_core_module.html#internal you > should > see that internal locations can't be accessed directly from > client/broby mrtn - Nginx Mailing List - English
hmm, so adding '^~' to the front of location /foo/bar/ makes "internal" directive work correctly. All direct access to "/foo/bar/sth/sth.html" are blocked with 404 now. However, the proxy_pass inside '/foo/bar/' location still doesn't work. I even put debugging echo inside all the location blocks, and only the /foo/bar one appears in the log file. But there is still no requeby mrtn - Nginx Mailing List - English
Hello Reinis, Thanks for pointing that out. Just to make sure I understand the doc correctly for my case. Given that: location /foo/bar/ (directive with conventional strings) and location ~* (\.jpg|\.png|\.css|\.js|\.html)$ (regular expressions). The /foo/bar/ location is actually checked and matched first, however, since I don't have a '^~' prefix in front of /foo/bar/, the search continuesby mrtn - Nginx Mailing List - English
Hello Valentin, No, it is not. I have a few other location blocks, but none of them should be matched to "/foo/bar". For examples, i have: location /foo/a/ location /foo/b/ location /foo/c/ also, location ~* (\.jpg|\.png|\.css|\.js|\.html)$ { valid_referers none blocked www.mysite.com static.mysite.com mysite.com; if ($invalid_referer) {by mrtn - Nginx Mailing List - English
A correction to my earlier post: the request in my first question above should be for "mysite.com/foo/bar/sth/sth.html", and there is a corresponding file on the filesystem: "/home/www/mysite/static/foo/bar/sth/sth.html". Just tried something different, with this config: root /home/www/mysite/static; location /foo/bar/ { internal; proxby mrtn - Nginx Mailing List - English
Hello, My question is two-part: 1. given the following setup: root /home/www/mysite/static; location /foo/bar/ { proxy_pass http://127.0.0.1:8080; proxy_redirect off; } Why a request for "mysite.com/foo/bar/sth.html" does not get proxied to the server at "127.0.0.1:8080"? Instead, the file "/home/www/mysite/static/foo/bar/sth.html&quoby mrtn - Nginx Mailing List - English
Hi Francis, >I guess (without testing): > >if ($arg_para != data) { return 404; } > >inside that location{} would probably work Hmm, I read on nginx website and elsewhere that if statement may not work consistently within a location directive, and is generally discouraged. Should I worry in this case? >The above rewrite does that; but which html file should it look fby mrtn - Nginx Mailing List - English
Hi Francis, Thanks for introducing me to rewrite directive. Just to confirm, this is how I should use your rewrite: root /home/www/example; location /public/doc/ { rewrite (.*)/(.*) $1/$2/$2.html break; } Ideally, for the other cases you raised, I want the following to happen: >http://www.example.com/public/doc/abc123 >http://www.example.com/public/doc/abcby mrtn - Nginx Mailing List - English
Hello, I am new to nginx, and am still learning my way. I use nginx to serve static html pages to users, and in particular, I want users who visit 'www.example.com/public/doc/abc123?para=data' to be served with the file '/home/www/example/public/doc/abc123/abc123.html' on the server, but 'www.example.com/public/doc/abc123?para=data' stays in the user's browser address bar. So there are twby mrtn - Nginx Mailing List - English