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
0
votes
1answer
28 views

Nginx restrict access to files in a directory but not in subdirectories

I implemented Nginx secure link module but can not get it working. I did read many posts on Serverfaulty and Stackowerflow but no success. I want to restrict access to any full size /image/video ...
0
votes
0answers
21 views

replace characters in URL/query string with Nginx

I've built a simple caching system for a PHP application I'm running, but wondering if it's possible to make Nginx do the cache checks to cut down on the memory overhead from PHP. And first, no I can'...
0
votes
1answer
41 views

NGINX regex get full url with everything except last forward-slash and query string

UPDATE: The solution in my case was this: map $http_host$request_uri $pageCache { default "nonexistent"; "~^(?<subdomain1>.{4})(?<subdomain2>.*)\.example\.com(?<folder1>.*?)...
0
votes
2answers
32 views

How to remove last request parameter of the URL from Nginx

I am new to Nginx, I am having one request URL coming with Token request parameter along with some other request pram. I just want to remove that Token parameter from the URL if its present. below ...
1
vote
1answer
78 views

Nginx: After removing .html suffixes, how to redirect all requests to the new URLs?

I want to optimize the link structure of an older Magento shop system. Until now, when generating the static pages, a .html suffix was added to the corresponding path. Due to an earlier problem, paths ...
0
votes
0answers
17 views

parsing haproxy log with regex

I have two haproxy log line first: Apr 13 03:49:00 localhost haproxy[90729]: 23.134.3.12:35138 [13/Apr/2020:03:49:00.404] http-in~ website1.com_b/website1.com 0/0/1/12/13 301 906 - - ---- 2/2/0/0/0 ...
0
votes
0answers
13 views

Linux sed: Extract value of a key in a string

I scoured the internet for a quick solution as i have less time to invest in reading the basics of regular expression as of now due to time constraints and thus here i am with the question below. ...
-2
votes
3answers
52 views

Parsing string via regex

How to parse the string output 5 Secs ( 2.2889%) 60 Secs ( 2.5874%) 300 Secs ( 2.6215%) to take only 2.6215
0
votes
1answer
97 views

NGINX Clean URL ReWrites. How?

I have spent several hours trying to figure out in NGINX what is otherwise and incredibly trivial task in Apache. I am exhausted... I have installed NGINX right out of the box. html is the root ...
0
votes
0answers
23 views

Fail2ban-regex matches from string but not from filter.d files

I'm trying to match wordpress failed logins and I'm struggling with fail2ban configuration. The lines I'm trying to match look like this: 116.147.121.40 - - [26/Mar/2020:10:18:24 +0100] "POST /wp-...
1
vote
1answer
27 views

use Regex to get a string from a file

I'm a beginner with regex Basically what I have on the line of my file is: grails.plugin.springsecurity.xxx.dtes.sp.file = '/home/share/9WR/config/application1-t-sp.html' // for unix file based ...
0
votes
0answers
58 views

NGINX Location Wildcard/Regex Not Working

I've tried countless wildcard/regex combinations to no avail for the below code. Basically just want it to capture any sub-directory of the /protected/ folder. If I use the below code for a specific ...
1
vote
3answers
126 views

editing nginx http headers

we are trying to migrate from apache to nginx, and we have a setup where the proxy server receives an http header, modifies it and forwards it to the backend. This can easily be done with apache in ...
0
votes
0answers
15 views

Haproxy path_reg compare number?

The paths are like this: https://example.com/10001/5235723gdh.jpg https://example.com/10007/836789370md.jpg We want to extract the number and compare. I tried with acl image1 path_reg \/[0-...
0
votes
0answers
18 views

Exclude files matching literal of wildcard

I would like use the rsync option --exclude-from to exclude a file containing expressions that exclude file paths with the following characters: |, :, ?, >, or <. It is unclear from the Rsync ...
0
votes
1answer
35 views

How to Set Regular Expression for Nginx Location Block and Proxy Pass?

I would like to ask about some configurations for Nginx; How to setup regular expression in Nginx location block? this is my configuration location ~ ^/web/api/v1/([A-Za-z]+) { proxy_pass http://...
0
votes
0answers
75 views

Suricata-update doesn't apply modify rules consistently

I have the following /etc/suricata/modify.conf file: ## Reject by classtype re:classtype:\s*attempted-user "alert(.*)" "reject\\1" # high Attempted User Privilege Gain re:...
0
votes
1answer
43 views

How can I create regular expression?

I need help with regular expressions. I have some queues in the rabbitMQ, about 1000: ha-collector-data-test2 ha-collector-data-1434 ha-collector-data-45-test3 ha-collector-data-terty4 ha-collector-...
0
votes
0answers
28 views

Is it possible to use a regex or a wordlist from an environment variable in an Apache 2.4 string comparison?

In Apache 2.4 we can use an environment variable in a simple string comparison expression, for example, assuming SOME_HOST_NAME is an environment variable: <If "%{HTTP_HOST} == env('SOME_HOST_NAME'...
0
votes
2answers
87 views

Nginx Redirect - maintaining the original domain name

i have my site domain.com in one server using nginx. Every-time that someone hit [1] example.com/~username i need that show the content of [2] http://example2.com/~username/ that reside in other ...
0
votes
1answer
24 views

Htaccess: some of the parameters doesn't work with GET?

.htaccess file RewriteEngine On RewriteRule ^/?([a-z]+)/([a-z]+)/market/(?!.* (css|js|jpeg|jpg|JPG|png|PNG|svg|ttf|otf)).*$ external/market/index.php?param1=$1&param2=$2&param3=$3&...
0
votes
0answers
33 views

Nginx proxy_pass with regex

I am trying to write an nginx location that would dynamically proxy_pass to backend_servers based on the URL requested. For example: If user requests from nginx https://nginxIP/1.1.1.1_farm_data-01/...
0
votes
1answer
49 views

Nginx get domain name and ltd based on simple server_name regex

I'm trying to get the current domain name and ltd for the current request using simple regex on server_name, the issue I'm having is that it is not setting any variables for $domain or $ltd. ...
0
votes
0answers
20 views

header_checks change subject for external domain only

I am going mad on a little problem I have here with header_checks. I try to change the subject of my emails of "[EXTERNAL] if !/^From: (.*)@domain.tld$/i /^Subject: (.+)$/i REPLACE Subject: [...
0
votes
1answer
205 views

Nginx rewrite arguments containing query strings with spaces

We have a SAS 9.4 VisualAnalyticsViewer page on a different host that I would like to present publicly over 443. The inside SAS server runs Apache Tomcat and listens on 8343 only. I would prefer not ...
1
vote
0answers
35 views

Puppet 4.10 Regex

I'm trying to add a 'type' layer to our hiera backend so webservers can get common configuration, databases get some common configuration, etc. Our hostname scheme is [env][number].domain.tld where [...
0
votes
1answer
26 views

Modify variable into log_format

I have simple config: http { log_format main '"rmethod":"$request_method" "uri":"$uri" "args":"$args"; access_log /tmp/nginx_access.log main; ... } Problem is that args ...
0
votes
0answers
11 views

How to add additional email validation rules by a python/perl script in Postfix?

In main.cf I have multiple restrictions, as usually: smtpd_NNN_restrictions = # ..... # ..... I want to be able to use an additional python/perl script in each section to make the final ...
0
votes
0answers
13 views

httpd DirectoryMatch Fails

I am trying to use IndexHeadInsert and DirectoryMatch to put notices at the top of mod_autoindex pages. Every regex I have tried does not want to work. If I put in IndexHeadInsert without the ...
0
votes
1answer
94 views

Why my Fail2ban regex doesn't find matches?

I have tried many regular expressions in fail2ban config, but it never return any matches. Line example: [2019-12-10 10:45:38] NOTICE[15077] res_pjsip/pjsip_distributor.c: Request 'INVITE' from '<...
0
votes
0answers
33 views

executing part of script coming from external file

I have some information stored in an external file. On the main script I'm parsing the secondary file to work out how information should be processed. To do so I have tried this: cat ./secondary....
0
votes
0answers
23 views

Nginx location block with regex won't match URL

This is my server block. server { set $auth_header 'Bearer my_token'; listen 80; server_name my.domain.com; location ~ "(/d\-solo/[a-zA-Z]{8,10}/.+\?.+)" { ...
0
votes
2answers
53 views

How do I cut just the file name from from ls -l output? [closed]

I am in the process of concatenating ogg audio files in bulk with the help of ffmpeg using a mylist.txt file The format of the mylist.txt file is file '/path/to/file1.wav' file '/path/to/file2.wav' ...
0
votes
1answer
102 views

Fail2Ban Regex Does Not Match

I am unable to get my fail2ban fail regex to get to match to the log entries. The following is a sample log entry: Failed login attempt {"xForwardedFor":"192.168.0.38","remoteAddress":"::ffff:127.0....
2
votes
1answer
25 views

Caret within parenthesis in RewriteRule

What does this mean: RewriteRule "(^|/)\." - [F] I know the F flag means to throw a 403 forbidden error. And I know the escaped period means that directories starting with a period are forbidden. ...
0
votes
1answer
493 views

Nginx rewrite map with query strings

I have a large rewrite-map.conf file which contains a number of redirects for a server however this does not work if there is a query string variable in the URL. For example my /etc/nginx/conf.d/...
0
votes
1answer
116 views

Modsecurity only allow access from two particular REFERER HEADERs

I have a Modsecurity rule which blocks all requests where the browser Referer Header is different from this: sub1.example.com. So basically the rule only allows requests when the Header Referer is ...
0
votes
0answers
240 views

Nginx rewrite directive negative lookahead doesn't work

I've a simple line in my Nginx configuration: rewrite "^\/(?!foo-bar).*" "$scheme://destination.url" permanent; This should redirect everything except URLs starting with /foo-bar. Somehow, this line ...
0
votes
0answers
42 views

mod_security does not block invalid URI requests

I am quite new to Modsecurity and need some help to secure my development server. I have Apache 2.4 installed with Mod Security 2.8.0 I have also installed OWASP ModSecurity Core Rule Set ver.3.2.0 ...
2
votes
1answer
55 views

Nginx proxy_pass long directive

i want to do proxy_pass from https://foo.bar/api/v1/users/{userId}/store/{storeCode}/status to https://bar.foo/api/v1/users/{userId}/store/{storeCode}/status and also from https://foo.bar/api/v1/...
1
vote
2answers
55 views

Supress 3Ware warnings in syslog

I'm trying to suppress the following warnings in my syslog: Oct 13 04:43:33 Winston kernel: 3w-sas: scsi1: ERROR: (0x03:0x0101): Invalid command opcode:opcode=0x85. Oct 13 04:43:33 Winston kernel: md:...
0
votes
0answers
120 views

Apache Redirect Permanent - Query String

I have a website, where I want to redirect all requests with a query against my domain, to the home page. http://www.example.com/?ref=something_query_string http://www.example.com/?ref=...
1
vote
0answers
43 views

haproxy compression type regex/wildcard

As stated in haproxy docs, we can use "compression type" with list of mime types. In my case, there is REST API backend, and the compression should be applied to multiple vendor-specific versioned ...
2
votes
1answer
2k views

Ansible split string on backslash

I'm passing a list of dir/subdirs into a playbook as follows: dirs=['Web\this','Web\that','Web'] This works fine when I actually do tasks on those directories (win_shell, invoking a build process), ...
1
vote
1answer
119 views

regex rewrite in nginx to match year in the URL

I am trying to write an nginx rewrite directive that redirects a URL like https://website.com/2018/11/20/dummytext/feed/ to https://website.com/2018/11/20/dummytext/ (removing the /feed/ in the end). ...
1
vote
0answers
29 views

Discard all outbound emails with exception of single subject using Postfix

How do I discard all emails before they're sent with Postfix if they don't end with a certain string? I've set up the below header_check regex but Postfix doesn't like it. Sep 12 09:09:24 evolve ...
1
vote
1answer
382 views

htaccess redirect from subdomain directory to main domain

I need redirect all requests from subdomain specific directory to main domain Example: dev.example.com/directory/test need to redirect to example.com/directory/test (redirect only requests with ...
1
vote
2answers
157 views

Fail2ban fails to recognize IP

I have a problem here where Fail2ban failed to recognize the IP, so I try to ban failed MySQL access, here are the syslog to be monitored Sep 6 01:45:18 vps6XXXXX mysqld: 2019-09-06 1:45:18 ...
0
votes
2answers
230 views

http header regex match apache

I have a header in apache that is too long, so I want to turn it into a subset. The header is a string and I'm trying to get it to become this subset: WANTED_SUBSTRING_MATCH(everything in between) [...
0
votes
1answer
346 views

NGINX replace string in $args

I would like to manipulate a parameter when the string /static/ exists on the src $arg_param in nginx. location ~ ^/customresize.php { if($args_param4 ~ /static/){ #replace /...

1
2 3 4 5
13