Questions tagged [regex]

When asking regex questions, always add the tag for the specific programming language or tool (e.g., Perl, Python, or Java; vi, emacs, or ɢɴᴜ grep; etc.) you are using.

Filter by
Sorted by
Tagged with
1 vote
1 answer
3k views

Postfix Header_Check Regex 'Does Not Match' issue

I am trying to configure Postfix to NOT accept outbound messages with FROM addresses other than my own domains. The following regex successfully rejects only 3 domains: /etc/postfix/header_checks: /(...
JustAGuy's user avatar
  • 649
0 votes
1 answer
1k views

Using RewriteRule to match RewriteMap value and ignore any trailing slash and characters?

I'm trying to use RewriteMap in a apache 2.4 virtualhost .conf file to redirect a number of URLs. A variety of requests can refer to a single entry in the map and I'm having trouble matching these ...
user354104's user avatar
4 votes
1 answer
5k views

fail2ban: regex to block \x00 requests?

Every once in a while my server goes down, and when I check my nginx logs, I usually see something like this: 78.37.54.31 - - [20/Apr/2016:20:58:51 +0300] "\x00\x00\x00TZ\x00\x00\x00\x00\x00\x00\x00\...
Isa Hassen's user avatar
0 votes
1 answer
2k views

Simple nginx server_name regex does not find match

I have an nginx box running version 1.8.1 on AWS. I am converting numerous DNS routing conditions into nginx and have encountered many DNS entries where *.yet_another_domain.* would be useful, but ...
REW's user avatar
  • 141
1 vote
0 answers
79 views

nginx and site.erb: tag as internal users for two different domains and two different sets of IPs

I have an nginx server and a site.erb file and two different domains (domain1 and domain2). Currently a tag (for Google Tag Manager) will be set when someone visits the sites from a particular set of ...
tomhafiz's user avatar
0 votes
0 answers
109 views

NGINX not recognizing $request

Well.. NGINX or me guess.. something that I'm not doing OK. The point is, I'm getting some request from bots of this type: 91.123.1.56 - - [04/Apr/2016:12:13:39 +0200] "V\x5CxA1po\x5CxA9^\x5Cx8F\...
lgg's user avatar
  • 151
0 votes
1 answer
654 views

Postfix header_checks and unicode regexp

Does postfix support unicode regular expressions like \p{Han} to detect unicode scripts? I would like to use them with header_checks.
Jean-François Beauchamp's user avatar
1 vote
1 answer
164 views

Rewrite bad url extention to .html in NGINX

A while back I made a mistake writing my urls and Google has them cached in old sitemaps. This is creating a ton of 404 errors in WMT that I need to clean up with a solid rewrite. I currently use the ...
Kanyin's user avatar
  • 13
0 votes
2 answers
3k views

Serving images from two different directories with Nginx

This should be basic... I'm brand new, and no amount of googling and searching stack exchange is helping. I have a website that I want to be able to serve images from, from different directories. I ...
farfie's user avatar
  • 3
2 votes
1 answer
2k views

mod_rewrite with multiple QUERY STRINGS

This is an extension to my question https://serverfault.com/a/761474/77231 I am trying to add an additional QUERY STRING parameter to the URL and change spaces to underscores but am having no success....
TryTryAgain's user avatar
  • 1,162
0 votes
1 answer
3k views

Regex nginx location with named location

I have the following set up - a production version of some software; location @myradio { rewrite ^/myradio/([^/]+)/([^/]+)/? /myradio/index.php?module=$1&action=$2 last; rewrite ^/...
LordAro's user avatar
  • 121
1 vote
1 answer
916 views

Nginx rewrite to remove .php from files has no effect but to redirect to homepage

I'm trying to make a rewrite to remove .php from my URLs but so far no luck. Here's what I've got so far and then my results with this config below. location ~ \.php$ { try_files $uri/ @...
Slbox's user avatar
  • 113
1 vote
1 answer
504 views

Exchange 2013 RegEx transport rule

I am looking to create some transport rules for outgoing email based upon AD properties. eg. Phone: 123-456-7890 Where the actual inserted code looks like "Phone: %%PhoneNumber%%", retrieving the ...
ltwally's user avatar
  • 325
-1 votes
1 answer
250 views

Nginx redirect 2 level subpaths

I have the following redirect rule: rewrite ^/path1/(.+)$ /path1/index.php?/$1 last; rewrite ^/path2/(.+)$ /path2/index.php?/$1 last; rewrite ^/path3/(.+)$ /path3/index.php?/$...
ayr-ton's user avatar
  • 103
0 votes
1 answer
53 views

.htaccess config not working properly

Here is my current situation: Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d [NC] RewriteCond %{REQUEST_FILENAME} !-f [NC] #the rule RewriteRule ^post....
user5869120's user avatar
0 votes
1 answer
1k views

Implement apache equivalent mod_rewrite functionality in lighttpd

Here's the mod_rewrite .htaccess file which is meant to work on Apache Servers for my web-app RewriteEngine On RewriteBase /cs200/tokens/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{...
Titanoboa's user avatar
  • 101
4 votes
1 answer
24k views

Block specific URL in HAProxy / url-encoding

I'm trying to restrict access to a specific URL. It should not allowed to access /admin.php. frontend example acl restricted_page path_beg -i /admin\.php http-request deny if restricted_page ...
user avatar
3 votes
1 answer
8k views

Insert a variable route path into nginx location configuration

I have a simple user based storage for images where I have a main folder say 'users' and within it, my server creates variable folders to store images for each user. The string used for the folder is ...
AlanZ2223's user avatar
  • 173
0 votes
1 answer
6k views

match special characters in url in nginx

I ran dotdotpwn to test transversal attacks on a web server using nginx/nasxi/doxsi and the only "successes" were urls that started with a question mark. No big deal since they just defaulted to the ...
gariac's user avatar
  • 1
1 vote
0 answers
345 views

Regex in Exchange transport rule

We are receiving external emails with invalid characters in the emails address which is causing issues for applications linked to the mailboxes. The receipient addresses contain single quotes ('name@...
Prak's user avatar
  • 11
6 votes
1 answer
14k views

url rewrite, nginx throw 404 errors, nothing in error logs

below rewrite works fine: rewrite ^/city/restaurants$ /city/listings/restaurants permanent; but this doesnt work rewrite ^/city/restaurants$ /city/listings/restaurants last; rewrite ^/city/...
Olaf Stavenger's user avatar
1 vote
0 answers
64 views

URL rewrite is producing 404

I'm trying to rewrite office.domain.com/app1 requests to server3:81 using the rule below, but I'm getting a 404. I can browse to server3:81 just fine. The Failed Request Tracing logs are available ...
InteXX's user avatar
  • 765
0 votes
0 answers
733 views

Redirect lang set in url with Nginx regex

I can't find the way to redirect the lang set in url with Nginx. I tried this: location ~ ^/(en|fr|de)/cloud/signup { return 301 $scheme://cloud.$host/$1/home/new; } Also this: location ^/(.*)/...
alex.bour's user avatar
  • 111
1 vote
2 answers
1k views

Exim: match recipient address against certain regex and conditional email delivery

I need to allow my customers to use e-mails in format of [email protected], where the username part is sort of UUID. Those emails should be delivered to certain (single) ...
jdevelop's user avatar
  • 153
6 votes
1 answer
3k views

Regex location block not working in NGINX

I have a pretty simple location block in my nginx conf that looks like this: location ~* ^\/[a-z0-9]{24}$ { // do some things } I'm attempting to catch urls that end in a Mongo ObjectId. eg: ...
jwerre's user avatar
  • 778
1 vote
1 answer
1k views

Fail2Ban regex to match these lines?

I've been trying to get fail2ban to work with the Xeams email spam filter. But, I can't figure out what possible regex I should use to match the logs. The logs are in this format. 61.240.144.65 ...
Felix Jen's user avatar
  • 403
3 votes
2 answers
323 views

ubuntu 14.04 Apache 2.4.7 mpm_event Files and FilesMatch not working

We recently switched our Apache 2.4.7 mode from mpm_pre-fork to mpm_event. Since then we haven't been able to get our Files directive to work. <Files "*.php"> Header set Cache-Control "no-...
Aaron's user avatar
  • 131
1 vote
1 answer
232 views

Is fail2ban not matching these lines just because of the port?

I would like fail2ban to engage against these lines and block the example IP address included: [Tue Dec 08 12:17:13.622175 2015] [:error] [pid 30390] [client 62.210.88.201:38139] script '/var/www/...
user3431540's user avatar
1 vote
0 answers
691 views

How do I set Host Groups on Fail2ban for Wordpress?

I'm trying to set up a custom filter for fail2ban on a wordpress site. I've been following this tutorial but when I try to test my custom filter, I get the error: server.failregex.RegexException: No '...
KempisCoder's user avatar
0 votes
2 answers
409 views

.htaccess rule to 301 redirect /?my_foo=bar to /foo/bar/

I tried, unsuccessfully, for hours to build (what I think is) a simple 301 redirect in an htaccess file. My url looks like this: www.example.com/?my_foo=bar And I want it to 301 redirect to: www....
Django's user avatar
  • 3
0 votes
2 answers
941 views

Prepend String using perl/awk/sed?

I'm trying to script a change to my apache config file (httpd.conf). I'm trying to match the following string: # # DirectoryIndex: sets the file that Apache will serve if a directory And PREPEND the ...
Brad's user avatar
  • 619
1 vote
1 answer
3k views

Nginx Config Location Regex With Language Code In Url

Trying to achieve constant language code in url's 1st segment with nginx regex location configuration and could not find the correct syntax. Necessary result: example.com stays example.com example....
Toms Bugna's user avatar
2 votes
1 answer
1k views

How to parse s3 logs?

I've been trying to parse AWS S3 logs following the documentation, but I've been running into some problems. Specifically, I keep running into new, rare log lines that break my regex. Every time this ...
Talia Stocks's user avatar
2 votes
0 answers
514 views

How to modify the message string being logged by syslog?

I have a few linux systems with the keyboard and console shared via a KVM switch. When I switch between them, I get a lot of unwanted syslog messages regarding the keyboard connecting and ...
Cor's user avatar
  • 51
1 vote
1 answer
632 views

Redirect page to 410 if match a specific Regex in .htacces

First time using .htaccess so I come here to have a bit of help since the web is not that file with informations (or I just don't find them :/). So the idea is that I want to redirect link ending by /...
Baldráni's user avatar
  • 133
3 votes
1 answer
12k views

Apache HTTP LocationMatch Redirect using Negative RegEx

I'm trying to create a Redirect using Apache HTTP Server's mod_alias and core on my system: # cat /etc/redhat-release Red Hat Enterprise Linux Server release 7.1 (Maipo) # rpm -q httpd httpd-2.4.6-...
alexus's user avatar
  • 13.4k
0 votes
0 answers
113 views

Rewrite /a/1/2 to /a.php using Nginx

I'm taking over a really old app and migrating it from apache to nginx. What I currently have. This works: # catch specific paths, rewrite to first segment # /a/1/2 => a.php # /b/3/4 => b.php #...
Thank you's user avatar
  • 279
0 votes
1 answer
1k views

Unable to use grep regex to search for filename containing period

Ubuntu 14.x. Using grep to search for all files linuxtest-client2. This includes multiple file extensions (csr, crt, key). When I grep for the middle portion of the filename, "2.", it also returns ...
lobi's user avatar
  • 1,093
1 vote
0 answers
123 views

nginx, redirect to remove a part of filename

I know there are plenty of questions how to replace part of URL with something else (or nothing) in nginx but I really suck in regular expressions and am absolute noob in nginx. So could anybody ...
Yuri Drobkov's user avatar
0 votes
1 answer
284 views

Determining e-mail server blacklisting from log files

I have my self-hosted e-mail server. There is no current problem of being blacklisted but I want to be proactive about it and I want to start with the log files. There have been some entries in my ...
gotgameg's user avatar
2 votes
1 answer
28k views

Reg Exp for URL in HAProxy

I'm trying to build a reg exp for haproxy that will match the second URL and direct it to a different acl than the first: mysite.com/path/ mysite.com/path/something_random The issue is that my first ...
Nimjox's user avatar
  • 217
2 votes
1 answer
447 views

rabbitmqctl set_policy drops caret (^) anchor from regex pattern

I am running this from PowerShell, so I'm not sure if this would happen in a different environment (the regex itself just includes everything except for those starting with 'amq.'). When I run the ...
Andrew's user avatar
  • 145
0 votes
1 answer
3k views

Nginx regex to get uri minus location

I have Nginx running as a reverse proxy to a couple applications. One location directive is running correctly, sending requests to a unix socket file and onwards to its upstream wsgi app. The ...
Palu Macil's user avatar
3 votes
1 answer
5k views

Fail2ban: regex test succeed but fail2ban does not ban any IP

I can't ban any ip, thought when I test my regex, it has +2000matches: > fail2ban-regex '/var/log/nginx/access.log' '/etc/fail2ban/filter.d/bad-request.conf' Date template hits: |- [# of hits] ...
Olaf Stavenger's user avatar
0 votes
1 answer
334 views

nginx regex rewrite rule for images

I have the following URLs: www.example.com/data/images/13122013-002_IM1621.jpg www.example.com/data/images/13122013-002_IM1622.jpg www.example.com/data/images/13122013-002_IM1622.jpg On the file ...
Lorenzo Garuti's user avatar
3 votes
1 answer
3k views

fail2ban regex filter doesnt work with nginx log files

I have been banging my head all day trying to match my regex filter to my access.log with no luck. I have installed fail2ban on a gentoo server and its running fine (i manually baned my own IP and it ...
user avatar
1 vote
1 answer
11k views

Configuring IIS rewrite module to redirect any host name to a specific host name

I have a website whose name I am changing from example.com to newexample.com. My thought process (please comment on this as well, as my approach may be incorrect) was to configure permanent a ...
Howiecamp's user avatar
  • 495
1 vote
0 answers
857 views

Fail2Ban regex in sshd.conf not catching failed root logins in /var/log/auth.log

I used Fail2Ban on my Ubuntu server (14.04 LTS), and it mostly works well. I recently noticed the default regex in /etc/fail2ban/filter.d/sshd.conf does not match some failed sshd login attempts. ...
David Jones's user avatar
0 votes
3 answers
324 views

Nginx rewrite and proxying

I am trying to combine these 2 Nginx location definitions into 1 location /v1/login { proxy_pass http://upstream/v1/login; proxy_redirect off; proxy_set_header Host ...
solefald's user avatar
  • 2,341
0 votes
1 answer
2k views

Nginx - Deny folder, except subfolders with regex

I want to deny access to anything in the app directory, except in subfolders with an Assets folder. For example: Allow these files /app/bundles/ApiBundle/Assets/css/Thing.js /app/bundles/...
that0n3guy's user avatar

1
6 7
8
9 10
15