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.

learn more… | top users | synonyms (1)

0
votes
1answer
1k 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 www/...
2
votes
1answer
1k views

How to block all incoming proxy visits except from one specific I.P?

I have a page that is prone to attacks, so, in order to reduce the anonymous attacks, I use this code in my .htaccess which I found online : # BLOCK PROXY VISITS <IfModule mod_rewrite.c> ...
1
vote
1answer
37 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\...
2
votes
1answer
3k 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
1answer
25 views

What's the error in my HTACCESS

index page and profile page show 404 after htaccess redirection I transfered from bogger to wp.. redirected all links from year/month/postname.html to postname/ using these lines: # WPhtc: Begin ...
0
votes
1answer
16 views

Logstash issue matching a substring of custom field

I have the following Logstash setup. Logs are piped to Logstash from Logspout via the logspout-logstash adapter, which adds a few fields to log messages, namely the docker.image field. I am able to ...
-1
votes
1answer
38 views

Nmap how to split and filter this(regex)?

I think i need a regex code to filter nmap output.txt I use a tool called: Word List Updater 2.7 so this is the output: http://pastebin.com/HwgiVHDA I want to filter,remove duplicates and look like ...
0
votes
2answers
5k views

Zabbix 2.0: Regular Expression to extract value from a String for a trigger?

I am using Zabbix 2.0.4 to monitor several Java applications. Most values are exported via JMX. One of those exported attributes is a string that is constructed like this: [IP_1],[port_1],[ms_time_1];[...
0
votes
3answers
304 views

nginx: regex not matching URI

i have this URI /orls/myservice/f?p=4550 and the following location location ~ "^/(.+)/myservice/f?p=(.+)$" { ..... } nginx is returning a 404 not found. the problem might come from the ? so i ...
2
votes
2answers
81 views

Apache2 LocationMatch allow an index for login but nothing else?

I want to allow /myapp and /myapp/ but disallow everything else. How do I configure this? I tried this: <LocationMatch "^/myapp/.+$"> LDAP here </LocationMatch> Which I would assume ...
1
vote
1answer
35 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: /(...
3
votes
1answer
2k 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 "http://my.domain....
0
votes
0answers
24 views

Fail2ban on CentOS, dovecot filters regex not matching logs

I'm starring at this regex for some time now and it seems perfectly matching lines from my log files but I can't get it to work, not even with modifications. I suspect the problem might be with the ...
0
votes
1answer
22 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 ...
8
votes
4answers
13k views

Using sed to remove both an opening and closing square bracket around a string

I'm running this command in a bash shell on Ubuntu 12.04.1 LTS. I'm attempting to remove both the [ and ] characters in one fell swoop, i.e. without having to pipe to sed a second time. I know square ...
2
votes
4answers
1k views

Sieve: filter subject with regex, file into mailbox named match

I am trying to filter mails by subject with a regular expression. The subjects I want to match are read like [git-foo] some more text where foo is the string I want to check for. I end up with the ...
4
votes
5answers
13k views

Copy multiple folders to a single destination with robocopy

I'm looking for a solution to use robocopy to copy several folders from a directory onto a distant network share. I want to choose several folders out of a directory that contains hundreds of folders ...
0
votes
1answer
34 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 ...
3
votes
6answers
8k views

Don't need the whole line, just the match from regular expression

I simply need to get the match from a regular expression: $ cat myfile.txt | SOMETHING_HERE "/(\w).+/" The output has to be only what was matched, inside the parenthesis. Don't think I can use ...
2
votes
4answers
5k views

apache locationmatch negative regex

I'm trying to expose a location through Apache. Normally, I have this block in my vhost that says <Location /> AuthType Basic AuthUserFile /web/.htpasswd AuthName "Test Site" ...
3
votes
4answers
1k views

Extract repository name from GitHub url in bash

Given ANY GitHub repository url string like: git://github.com/some-user/my-repo.git or git@github.com:some-user/my-repo.git or https://github.com/some-user/my-repo.git What is the best way in ...
0
votes
6answers
196 views

Sed regexp /d deleting whole file

Given a typical known_hosts file: [123.45.67.89]:22 ssh-rsa bbuivvhbkbjdnflksndkfnksnfk... [98.76.54.32]:14444 ssh-rsa hohdibsodbfoasbfbsabdfbsd... [77.34.122.33]:32209 ssh-rsa ...
0
votes
0answers
7 views

Odd regex behaviour matching newlines with s and m modifiers

I wish to remove a block of code from a file - along with any unnecessary newlines. Input file 'test' <block 1> nothing here </block> <block 2> foo bar </block> <block 3&...
1
vote
0answers
19 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 ...
0
votes
0answers
21 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\...
0
votes
0answers
37 views

fail2ban regex correctly write

Sorry for my bad english. Server nginx. Block /administrator/ http_access_module nginx-error.log [error] 10934#0: *11435 access forbidden by rule, client: 213.87.x.x, server: localhost, request: "...
2
votes
1answer
236 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 ...
0
votes
1answer
26 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.
1
vote
1answer
24 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 ...
1
vote
2answers
800 views

How to check if LocationMatch regex is working?

I have location match regex ScriptAlias /script /var/www/somescript.bash Action some-handler /script virtual <LocationMatch "/(?:\w+:)?\/\/[^\/]+([^?#]+)/"> SetHandler some-handler </...
0
votes
2answers
40 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 ...
2
votes
1answer
97 views

mod_rewrite with multiple QUERY STRINGS

This is an extension to my question http://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. ...
0
votes
1answer
5k 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 ...
0
votes
0answers
58 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 ^/...
0
votes
1answer
5k views

postfix header_checks using regexp proper setup

I just can't seem to figure out why header_checks are not being evaluated. I'm on Ubuntu 12.04, postfix 2.7, dovecote, spamassasin, clamav, amavis. I add following line to /etc/postfix/main.cf : ...
1
vote
1answer
24 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/ @...
1
vote
1answer
309 views

Postfix bad notify parameter syntax

Please bear with me as I'm not an expert admin I have a linux mail server that has been running for a couple of years and now all of a sudden a certain user is unable to send emails. They immediately ...
1
vote
1answer
45 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 ...
3
votes
2answers
71 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-...
0
votes
1answer
673 views

postfix header_checks - regex spanning multiple lines

I would like to create a spam filter that spans multiple lines in headers. This is my /etc/postfix/header_checks file: /^From:.*name[0-9]+@.+[\r\n]+To:.*name@domain\.com/ REJECT It's a valid regex,...
-1
votes
1answer
37 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?/$...
1
vote
2answers
484 views

Moving mod_rewrite rules in .htaccess to httpd.conf

I've got a massive set of URL rewriting rules that I am trying to: optimize transition to use within httpd.conf But I'm facing problems in getting the final product to work. Note: There are ...
0
votes
1answer
150 views

nginx naxsi $URL_X doesn't work

Recently recompiled my NGINX with a NAXSI module. Now setting up the white lists but the $URL_X functionality doesn't seem to work at all. Generating Incorrect line BasicRule wl:1312 in NGINX ...
0
votes
1answer
15 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 %{...
0
votes
1answer
31 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....
0
votes
1answer
421 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 ...
0
votes
1answer
34 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 ...
0
votes
2answers
250 views

htaccess rule to rewrite %3F to ? and %3D to =

I need to rewrite the URL of my site which contains %3F to ? and %3D to = I have tried this rule: RewriteCond %{HTTP_HOST} myhostname RewriteRule ^(.*)%3F(.+)%3D(.+)$ $1?$2=$3 [L,R=301] ...
1
vote
1answer
107 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 ...
0
votes
1answer
185 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 ...