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
0 answers
26 views

Filter request header with regular expression in apache

I have a requirement to send a response header by filtering the request header string in apache. To filter the string, a regular expression can be used. The echo command is working fine to send the ...
user avatar
0 votes
1 answer
60 views

Fail2ban : regex used in failregex does not work (square brackets ] issue ?!)

With fail2ban, I want to ban IPs based to the content of apache_access.log file. This is an example of line I want match with regex rules : 197.221.254.56 - - [13/Jun/2022:22:59:59 +0200] "GET / ...
user avatar
0 votes
1 answer
19 views

Is it possible to access a modified query string in a RewriteCond *after* applying a RewriteRule?

Is it possible to access a modified query string in a RewriteCond after applying a RewriteRule? What I'm trying is to apply ... RewriteCond %{QUERY_STRING} ^(.*)&?id=([^&]+)&?(.*)$ [NC] ...
user avatar
  • 111
0 votes
1 answer
45 views

Ansible regex_search module

Can anyone please help me to explain this code in ansible regex_search module: - set_fact: regex: "{{ '/opt/conf/path.txt' | regex_search('/?(.*)', '\\1') }}' What "\\1" means in ...
user avatar
0 votes
1 answer
36 views

Editing fail2ban apache-noscript config to add "AH10244: invalid URI path"

I have the following (default) /etc/fail2ban/filter.d/apache-noscript.conf configuration file: [Definition] script = /\S*(?:php(?:[45]|[.-]cgi)?|\.asp|\.exe|\.pl|\bcgi-bin/) prefregex = ^%(...
user avatar
  • 73
0 votes
1 answer
41 views

Regexp for header_checks in postfix

All my users use outlook, so the From field reaches the postfix like this: From: "Name and Surname" address@something.com. I need a regular expression to change the address, I have this in ...
user avatar
  • 1
0 votes
1 answer
17 views

Having trouble getting a regex to redirect traffic to work correctly

I'm trying to setup some 301 redirects on WPengine using regex and I'm having trouble getting things working. Old URL: https://www.website.com/abc/123 New URL: https://www.website.com/abc For pages ...
user avatar
0 votes
1 answer
62 views

In Using pfSense HAProxy - to check the url if it has a sub domain name

I have a wildcard Cert and need to direct any sub domain name that does not exist to a custom 503 error page and don’t want to use the Frontend’s Error files feature nor its default 503 page. I want ...
user avatar
0 votes
0 answers
39 views

Zabbix 6 : Elastic Search Trigger Expression no longer working

I just updated our Zabbix server from v5 to v6 and all went pretty smoothly. One of the problems I'm running into post-upgrade are the triggers we use to monitor Elastic Search. We have a custom ...
user avatar
  • 111
0 votes
0 answers
21 views

nginx 301 redirect only regex matched url

I need to permanent redirect only urls where the first 3 chars are NOT numbers example url to redirect /category/televisione/ /chi-e-alvin-eta-vita-privata-moglie-e-carriera-in-tv/ example url don't ...
user avatar
1 vote
1 answer
247 views

Nginx match any word in if statement except one

I'm using the following if statement regex in nginx config to match and block some bad requests inside request uri. These bad queries request always only one argument but every time with random name (...
user avatar
  • 155
1 vote
0 answers
27 views

How do I convert this .htaccess snippet to Nginx rules?

I have this snippet of .htaccess coming from Apache: RewriteCond %{REQUEST_FILENAME} index\.php RewriteCond %{QUERY_STRING} ^id=([0-9]+)$ RewriteCond %{DOCUMENT_ROOT}/u_pages/%1.php -f RewriteRule .* ...
user avatar
0 votes
0 answers
40 views

How to define a location by a string in URL using NGINX

I have the URL: https://mysitedomain:8443/app/visualize?security_tenant=global#/edit/9e5fc420-89cd-11ec-b13a-ddde90ebb494?embed=true&_g=(filters%3A!()%2CrefreshInterval%3A(pause%3A!t%2Cvalue%3A0)%...
user avatar
  • 1
0 votes
1 answer
222 views

Nginx reverse proxy reach my site but can't get pictures

I've been struggling for 3 days with Nginx reverse proxy to realize i think, a easy thing. I have to simply reach many backend node-red (nodeJS) application from Nginx but always, with different ports....
user avatar
0 votes
0 answers
23 views

Regular expression to consider all directory and remove if particular folder matches

I want to write a regular expression to consider all the directory which start from "system" and delete if particular folder struture present with name "Remote" currently Provided ...
user avatar
0 votes
2 answers
79 views

fail2ban not banning "matched" IPs from vsftp log

Using fail2ban to secure the vsftp login: jail.local [vsftpd] enabled = true bantime = 600 findtime = 5000 maxretry = 1 port = ftp,ftp-data action = iptables-multiport logpath = /var/log/vsftpd/...
user avatar
0 votes
1 answer
49 views

nginx reverse proxy IP_adr/1881 to localhost:1881 proxy_pass

I have read this post, and try many thing but i have issue with rewrite regex. here I have many node.js processes as backends with always different port to access. With Nginx reverse proxy in the same ...
user avatar
0 votes
1 answer
217 views

NGINX: reverse proxy path to subdomain and append the rest

I have the following NGINX configuration file: server { server_name devices.example.org; ssl_protocols TLSv1.2; ssl_certificate /etc/ssl/web/example.crt; ssl_certificate_key /etc/ssl/web/...
user avatar
  • 105
0 votes
0 answers
42 views

Broken non english url on redirect in Nginx

I am running WordPress on the NginX server. And I have a problem with permalink getting the query string ?nonamp=1. So I want to redirect like this: example.com/abc/?nonamp=1/ redirect to example.com/...
user avatar
0 votes
1 answer
216 views

fail2ban: apache-badbots is not working

I have a working fail2ban configuration which not only blocks IPs but also announces them to the AbuseIPDB. This is working fine for sshd and postfix-sasl, but not for apache-badbots (and resultign ...
user avatar
  • 101
0 votes
1 answer
231 views

rsyslog: regex extract between 2 strings

I want to extract a substring of msg field between 2 strings. Example of the log: Test local logging: db=testdb,message What I want is "testdb", so, the string between "db=" and &...
user avatar
  • 1
1 vote
1 answer
96 views

rewrite and force redirect on rewrite origin url in nginx

I have this instance where a html search <form> forces it to go to /search/index.php?q=term and would like to use something like /search/term instead. This is how the config looks like right now:...
user avatar
  • 147
0 votes
0 answers
30 views

Apache Filesmatch regex issue

I'm trying to block all files that contains the keyword cpf and I've entered this into the apache2 configuration: <FilesMatch "cpf.*$"> Require all denied </FilesMatch> and ...
user avatar
1 vote
1 answer
37 views

Sending selective args from Nginx proxy to the upstreams through proxy_pass

I have a Nginx proxy configured for a Minio S3 object storage server. Can I remove some of the query params (more than one agrs) when I'm passing a request to the upstream (Minio) and keep the rest of ...
user avatar
0 votes
0 answers
82 views

Using Powershell to check System logs for Log4Shell

I´m currently trying to check logs on different windows machines to check, if any Log4Shell attacks were run against our systems. The groundwork is done and easy regex patterns can be checked. If I ...
user avatar
0 votes
0 answers
33 views

Nginx - Is there a way to apply a fail rule on a regex only if you're not within a location block?

In my nginx config I have if ( $query_string ~ "author=([0-9]*)" ) { return 403; } to block author queries on the frontend from leaking sensitive information. The problem is this also ...
user avatar
  • 111
1 vote
0 answers
510 views

Using URL's with special characters in nginx maps

When using nginx and maps it is possible to rewrite mutiple URL's with a map file. What is problematic is when the URL contains special characters. I have been breaking my head trying to get this ...
user avatar
  • 203
0 votes
1 answer
48 views

htaccess match all words until last slash and redirect 301

I'm trying to escape everything until the last slash, even if there's a slash in between. Example: /site_url/courses/cat1/cat2/subcat/coursename to /site_url/course/courseName or /site_url/course/...
user avatar
  • 3
1 vote
1 answer
342 views

Docker run environment variable regex / wildcard

On my host machine I run the following: export test_1="Hello" export test_2="There" Starting Docker container: docker run -it -e test* centos The env variables are not available ...
user avatar
0 votes
0 answers
58 views

URL Redirect does not work when pattern matches part of the redirect url

I want the wildcard pattern “mysuburl*” to redirect to “http://localhost/mysuburl.html” although I get a too many redirects error. The redirect is successful though if I use a pattern that differs in ...
user avatar
0 votes
1 answer
714 views

kubernetes ingress replace path

I have two backend api-services: api-service-v1 api-service-v2 Both respond on "/api/" path I have this configuration running fine as a docker-compose setup where nginx service serves as a ...
user avatar
0 votes
0 answers
69 views

Apache rewrite condition not matching, possibly bad syntax?

Hi so I have a rewrite rule in order to control access to the admin page of a service behind a reverse proxy. I only want local ip's to be able to access it. So essentially if the condition does NOT ...
user avatar
0 votes
0 answers
70 views

neg. lookahead not working for postfix header

I'm trying to exclude all emails not received from a mainstream domain The full postfix regex in /etc/postfix/header_checks is: /Received:(?!.*\.((net|com|edu|gov|org|info)))/m DISCARD Bu the negative ...
user avatar
0 votes
1 answer
166 views

Mobile redirect in nginx with query string

I'm trying to redirect mobile visitors to AMP pages with nginx. I've basically using the script @ https://gist.github.com/dangayle/2919206 with recommended modifications, plus elements from the answer ...
user avatar
  • 103
0 votes
1 answer
61 views

Regex does not work with grep

Why does this match .*\/.+\/wp-admin.*404 [03/Sep/2021:18:58:29 +0200] "GET /up/wp-admin/install.php HTTP/1.1" 404 6197 regexr.com But in grep it does not? sudo grep -rh ".*\/.+\/wp-...
user avatar
0 votes
1 answer
168 views

dig - get only hostnames

Could someone help me if there exists some way how to get from dig only hostnames if I want to get list of DNS zone? I work with this command: dig @dns.example.com example.com axfr output is: ...
user avatar
1 vote
1 answer
7k views

Removing specific characters from a string on ansible

I have the following - set_fact: test_result: " {{ htmlres.content | regex_search('http://website([0-9]+)', '\\1') }}" Using debug, this returns the following " '[01]'" Wanting ...
user avatar
  • 25
0 votes
0 answers
816 views

Ansible: extracting a string between two strings

So I have an html file that contains the following somewhere in the middle: <span dir="ltr">http:(...).com</span> I'm attempting to extract the url, but am having some issues ...
user avatar
  • 25
1 vote
0 answers
135 views

Haproxy: Restrict access to untrusted IPs only to sub url

I would like to restrict access to my pastebin server (I'm using zerobin) so that untrusted IPs can only open secrets, but not create them. (note that the url https://fakepastebin.com below is just an ...
user avatar
  • 65
0 votes
1 answer
2k views

Append URL parameter to request URI using Nginx

I'm trying to append URL parameters to specific request URI's within the server block. This is what I have so far: if ( $request_uri = "/testing/signup" ) { rewrite ^ https://www.example....
user avatar
0 votes
0 answers
34 views

Fail2ban regex for multiple IPs which includes LB IPs into it

Struggling with the correct regex for the below log which I am not able to parse to get it working with fail to ban. I need XX.XXX.XX.XX to be checked via fail2ban. Please assist which me the correct ...
user avatar
0 votes
0 answers
58 views

Openldap / Filter & dn.regex

I would like to know if it is possible to configure openldap to use both filters and regex on the DN. {1}to dn.regex="ou=gBook,ou=(c[0-9]+),dc=test,dc=net$" by dn.regex="uid=([^,]+),ou=...
user avatar
0 votes
1 answer
151 views

How do you use regex flags in postfix?

In Postfix we can apply some basic header, body, client checks using regex. I wanted to use flags. I added the following to the header_checks file: /some(\s|_|-)words(\s|_|-)here/gmi REJECT and tested ...
user avatar
1 vote
1 answer
222 views

Fail2ban regex working but not banning. DNS warning instead

I had the following problem (already solved) with fail2ban and misplaced it on stack overflow so I'm putting it here now. So, I've been reading issues for some days and don't seem to find a solution ...
user avatar
  • 31
1 vote
1 answer
863 views

Nginx location matching with regex year/month/day/*

I have some old url pattern to redirect to new location in nginx. A typical clean url looks like example.com/2021/06/13/78676.html?.. Im roughly trying to match number of digit in each block like: ...
user avatar
  • 33
0 votes
1 answer
234 views

nginx: Location block for all URIs without extension

I know how to process URIs that match a certain pattern. Example The following configuration will add an Cache-Control http-header to all files ending with .css or .js: location ~* \.(css|js)$ { ...
user avatar
1 vote
1 answer
60 views

Why does this regexp match, but not location / in NGINX

I basically have those two locations in NGINX (Return codes added for debugging purpose) location / { return 401; } location ~ "^/(assets|((de|en|es|fr|it|zh|ru)-[a-z]{3}))" { ...
user avatar
  • 456
0 votes
1 answer
44 views

Nginx not captures regex variables

Trying to capture URLs like http://mydomain/1234567890123 (13 digits) location ~ ^/([\d]{13})$ { proxy_pass http://127.0.0.1:4000/product?id=$1; } $1 variable arriving empty, ...
user avatar
  • 101
0 votes
1 answer
782 views

Ansible regex didn't match command output - Empty list -

I'am trying to get the list of the device ID and the list of the port Id with ansible with regex but i get an empty list, below the output that i'am trying to parse it : Device ID Local Intrfce ...
user avatar
0 votes
2 answers
74 views

Need assistance to rewrite url in Nginx for WHMPRESS

I need to rewrite URLs in NGINX. I tried many examples from google searches but failed. /manager/?whmpca=order_process&a=add&pid=5&a=add&currency=1&billingcycle=monthly I need to ...
user avatar
  • 11

1
2 3 4 5
14