0
votes
1answer
23 views

nginx regex configuration for 404 images

I have dynamic link series like below; http://example.com/users/1871233/18712443_cover.jpg Only static thing is on that link is example.com/users and _cover.I want to make that ; when requested is ...
2
votes
2answers
118 views

nginx rewrite regex for API versioning

What I want is for the first to be turned into the second.. /widget => /widget/index.php /widget/ => /widget/index.php /widget?act=list => ...
0
votes
1answer
58 views

Matching %ff in Nginx rewrite rules

I have some dubious requests coming into my server that contain %ff and %FF (e.g., /blog/%ffupdates/. I'm getting thousands of these daily and would like to start redirecting them to a 403. I ...
0
votes
0answers
36 views

Using regex with several locations in nginx

I have dynamic number subfolders of the domain. For example: http://mysite/en/ http://mysite/en-us/ http://mysite/de/ http://mysite/ru/ In general, subfolders look like "en","de","ru" OR "en-us", ...
1
vote
1answer
49 views

Show real server name in nginx logs and params passed to fastcgi?

I have configured my nginx vhosts with a regex in server_name. nginx shows the raw regex in logs and in params passed to php-fpm (I know there's $_SERVER['HTTP_HOST'] with a real value, that's not an ...
0
votes
1answer
130 views

Optional URL segments in NGINX

I need to proxy pass multiple segments further to another server, there can be up two 5 segments. What nginx needs to match example.com/somehash example.com/somehash/segment1 ...
1
vote
2answers
259 views

nginx url rewriting. i just don't get it

Ok, an example url is http://www.mysite.com/?p=account&view=settings the p uri is a constant. all urls have it. the view is one of many optional uri. i've tried to understand url rewriting ...
0
votes
1answer
73 views

Nginx Extract Top Directory Name From Request URI

I am in the need of being able to use top directory from the $request_uri, for example: /dir/sub/slug -> /dir I read the answer of this question: How to extract Only the file name from the request ...
1
vote
1answer
343 views

Nginx redirect all old domain subdomains to new one

I had a very long domain, so I decided to change it to a shorter and more friendly one. But since I have a lot of subdomains (in fact, I have a subdomain wildcard), I wanted to keep the subdomain ...
2
votes
1answer
382 views

nginx return 301 / redirect

among all 'redirect in nginx' questions I couldnt find how to redirect (using return 301 and beteer no ifs) using regexps. I have a link to my website and I'd like to remove parameter a the end: ...
0
votes
0answers
34 views

Issue with a NGINX Location regex

I'm just dealing with a location issue today, I have a customer domain with the following format: subdomain.domain.tld and urls as: subdomain.domain.tld/servicename I'm trying to forward this ...
1
vote
1answer
162 views

Whitelisting valid URL patterns on a NGINX webserver

I want to whitelist only valid URL-patterns on our RESTful webserver / API, using regexs or something. But when googling for some examples I get a little bit suspicious since there is not much ...
0
votes
1answer
51 views

Location regex acting weird on NGINX

I come to you today with a super strange comportment on my NGINX reverse proxy. I use it to be the reverse proxy of a tomcat server and set the host configuration like that: server { listen ...
0
votes
1answer
3k views

Nginx location regex is not matching

The following has been working to cache css and js for me: location ~ "^(.*)\.(min.)?(css|js)$" { expires max; } results: $ curl -I http://mysite.com/test.css HTTP/1.1 200 OK Server: nginx ...
0
votes
0answers
120 views

How to exclude a URL from mod-rewrite with nginx?

I'm moving my Joomla! 2.5 from Apache Ubuntu to Debian nginx and I need to exclude some URLs from the mod-rewrite. Now I'm rewrite all within this directive on the IspConfig panel: # mod_rewrite url ...
0
votes
2answers
3k views

Nginx: location regex for multiple paths with backend

I have two locations in nginx config that work: location ^~ /media/ { proxy_pass http://backend.example.com; } location ^~ /static/ { proxy_pass http://backend.example.com; } How can I combine ...
1
vote
1answer
90 views

fail2ban jail not working properly

I'm trying to block non-available script requests to nginx with fail2ban. # Noscript filter /etc/fail2ban/filter.d/nginx-noscript.conf: # # Block IPs trying to execute scripts such as .php, .pl, ...
0
votes
1answer
502 views

Ngnix Rewrite - If URL contains

I'm having a small issue - my error log is filling up with requests to a directory folder on my site (but with added data that shouldn't be there). http://example.com/the-directory/undefined ...
0
votes
1answer
142 views

NGiNX and MediaWiki rewrite regular expression

I am having some problems with regular-expression with rewrite in NGiNX. Here is my config: location /wiki/ { rewrite ^/([^?]*)/([^?]*)(?:\?(.*))? /$1/index.php?title=$2&$3 last; ...
1
vote
0answers
75 views

Nginx - Adding a trailing slash to urls on HTTPS

I am using the below regex to add a trailing slash to any url that doesn't have a railing slash or ends ends with .. rewrite ^([^.]*[^/])$ $1/ permanent; This works fine for http, but when I use ...
0
votes
1answer
175 views

nginx dynamic servername with regular expression doesn't work for co.uk

I'm trying to setup a nginx server which dynamically loads content from a folder for a domain. To do this I'm using regular expressions in the server name like so: server_name ...
0
votes
1answer
286 views

nginx rewrite rules with regex applied to one subdirectory only

I've been frustrated for days trying to figure this out, so any advice/help would be greatly appreciated! I've recently added a section called /links to a site at somehost.com but can't seem to get ...
0
votes
1answer
67 views

serve a static file in nginx based on domain extension.ltd?

I was wondering and already did some extensive searches on how to serve a static file based on the domain.LTD extension. Nginx.conf: error_page 502 /maintenance.html; location = /maintenance.html { ...
0
votes
1answer
130 views

NGINX Drupal Redirect for Mobile

What I want to do; I want mobile users to be redirected to http://m.site.org/mobile-home. Being redirected to the m.bzaeds.org isn't an issue. I also have this working fine in Apache, but the same ...
1
vote
1answer
206 views

nginx + regex, remove all parts of URI except the last one

With an URI like /a-part/some-part/another-part/last-part/?some_param=some_value how do I go about removing everything up to the last part with params and ultimately rewrite it to look like ...
0
votes
1answer
2k views

Nginx match multiple paths in location directive

I have the following directives in my nginx conf, that are working correctly: location = /favicon.ico { root /home/www/myapp/static/ico; } location ^~ /apple-touch-icon { root ...
1
vote
0answers
57 views

Nginx reverse proxy using a hashed part of the url

to optimize local caching, I would like nginx to loadbalance requests based on only a part of the URL. For example: a) www.example.com/a/123123/b b) www.example.com/a/123123/c/d c) ...
0
votes
1answer
868 views

Nginx location override does not do what I want, opinions welcome

I have a Nginx configuration file that works for everything except one feature. I have installed a Mediawiki, it works pretty well except at showing pictures (loading them works fine). Whereas (sorry ...
1
vote
1answer
518 views

Regular expressions in server_name with Nginx vhost

I have something I'm trying to do with Nginx. Say I have a few users and a subdomain, and each user has a directory at /home/dev/sites/USER_ID. I would like for USER_ID.dev.example.com to point to ...
0
votes
1answer
854 views

Extracting matches in NGiNX with regex without if block

With NGiNX I get a string that contains information that I can extract content with regex. But the only way I found that I could do this, is with if block. Is there any another way? The extracted ...
1
vote
1answer
429 views

Nginx - Redirect request by GET parameters pattern

One of my servers was attacked by DDoS a couple of days ago and it lasted for 4 days. Below are the logs snippet of the request: 36.224.180.253 - - [14/May/2013:03:11:46 +0800] "GET ...
1
vote
1answer
49 views

Nginx 404 rewrite issue

I'm trying to grab variables between slashes and pass them to my management script with the following rewrite line in Nginx: rewrite ^/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)$ ...
0
votes
2answers
1k views

nginx simple regex location

I need to set a location param in nginx if the first 5 digits of the url are numbers. site.com/12345/ or site.com/12345 But I can't for the life of me seem to get the correct regular expression. ...
0
votes
1answer
53 views

nginx rewrite and Drupal

My web root is in /staging/ and I'm currently using this rewrite line: location / { # This is cool because no php is touched for static content try_files $uri @rewrite; } ...
0
votes
1answer
354 views

How to have nginx serve only the home page of site?

I am running a server with nginx on port 80 and Apache on 8080. I want the home page of my site to be served with nginx, and every other request passed through to Apache. I found this great article ...
0
votes
1answer
667 views

nginx httpMapModule regex variables

The HttpMapModule documentation states that: Since 1.0.4, case insensitive regular expressions can be used by prefixing the pattern with ~*. And gives the example: map $uri $myvalue { /aa ...
0
votes
1answer
125 views

Nginx Config File Regex Issue

I am trying to convert the following rewrite rule into a 'try_files': location ~* \.(css|js) { if (!-f $request_filename) { rewrite ^/wp-content/w3tc/min/(.+\.(css|js))$ ...
0
votes
2answers
381 views

Nginx RegEx to match a directory and file

I'm wondering if it's possible to match Wordpress directory and specific file in the same location, so at the moment I've got rule to match only the wp-admin directory: ## Restricted Access ...
2
votes
1answer
1k views

nginx: [emerg] unknown “script_filename” variable

I'm receving this error when trying to use script_filename nginx: [emerg] unknown "script_filename" variable nginx: configuration file /etc/nginx/nginx.conf test failed However script_filename is ...
1
vote
1answer
402 views

Convert from apache rewrite to nginx

I want to convert from apache rewrite modules to nginx RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR] RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR] RewriteCond ...
0
votes
1answer
582 views

Nginx alias and regex

i'll need a bit of help for alias on folder with nginx I have my folder www/ with the container of my site example.com and a lot of folder like client0, client1, client2... I should NOT modify ...
1
vote
1answer
415 views

trouble with location regex and redirection in nginx

I want to setup proxy in nginx: location ~ ^/m/([^/]*)/([^/]*)/([^/]*)$ { proxy_pass http://127.0.0.1:8080/redir/m/$1/$2/$3; proxy_redirect off; proxy_set_header Host $host; proxy_set_header ...
0
votes
2answers
316 views

Need custom Nginx regex

Following is what I have right now and it works but needs some improvement. I am guessing that I will need to use regex and that is why I need help. What I need is this ...
0
votes
1answer
98 views

Need nginx regex rewrite debuging help [duplicate]

Possible Duplicate: Need custom Nginx regex Desired outcome is this: http://www.example.com/about/?r=something to this: http://www.example.com/about.php/?r=something This is what I ...
1
vote
2answers
1k views

NGINX Reverse Proxy : proxy_cache inside if block - Possible?

I think starting with a small snippet would be wisest: location ^~ /test/ { proxy_pass http://frontend; proxy_http_version 1.1; ...
5
votes
1answer
433 views

nging pcre_compile error when using quantifiers

I'm having an issue with aliasing. I want to append up to the first 4 digits of the file as part of the directory. (like '../123456.jpg'=>'../123/123456.jpg' and '../12.png'=>'../12/12.png') Here is ...
4
votes
4answers
3k views

nginx rewrite base url

I would like the root url http://www.example.com to redirect to http://www.example.com/something/else This is because some weird WP plugin always sets a cookie on the base url, which doesn't let ...
1
vote
0answers
169 views

Nginx equivalent to lighttpd “evhost.path-pattern”

I'm setting up a new server for my personal stuff. On the old box I've used lighttpd for almost two years now. I've read a bit about it and most people tend to switch to nginx since it's development ...
0
votes
2answers
344 views

Nginx: wild card dns redirect URL to subdomain

I'm trying to redirect the following URL Http://example.com/category/something To redirect to Http://something.example.com/category/something Where "something" could be anything. I've already ...
1
vote
1answer
954 views

nginx regex characters that require quoting?

So I was configuring nginx today and I hit a weird problem. I was trying to match a location like this: location ~ ^/([0-9]+)/(.*) { # do proxy redirects } ...for URLs like ...