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.
Questions tagged [regex]
720 questions
0
votes
1 answer
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 the file header_checks:
/^(From: "(?:[^"]|"")*"…

roch3
- 1
0
votes
1 answer
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 that do not have the first part of the URL…

Windows Ninja
- 2,586
- 19
- 46
- 70
0
votes
1 answer
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 my Backend’s to handle all error pages, but on the…

VcDeveloper
- 99
- 3
0
votes
1 answer
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.
For the next, this my example :
Web client ->…

dinastar66
- 1
- 2
0
votes
2 answers
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/vsftpd.log
Regex is matching, as you can see…
0
votes
1 answer
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 server i want to pass for exemple :…

dinastar66
- 1
- 2
0
votes
1 answer
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/example.key;
location ~* ^/(.*)(.*)?$ {
…

Vapire
- 105
- 3
0
votes
1 answer
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 from that I would assume apache-overflow isn't…

Elmi
- 101
0
votes
1 answer
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 ","
This is my configuration:
template(name="jsonTemplate"
…

dcop7
- 1
0
votes
0 answers
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:
Require all denied
and this blocked a file called name.cpf, but not name.cpfs and…

Adam Larsson
- 31
- 1
- 6
0
votes
1 answer
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/courseName
How could I achieve this with Nginx…

farroh
- 3
- 1
0
votes
0 answers
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 lookahead is failing to match longer header…

Michael Sandy
- 11
- 1
0
votes
1 answer
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 @ add a URL suffix path (for mobile AMP) without…

cnxsoft
- 103
- 2
0
votes
1 answer
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-admin.*404" /var/log/apache2/ | wc -l
0
I know the line exists in…

lampstackxyz
- 27
- 5
0
votes
1 answer
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:
example1.com. 1200 IN A 1.1.1.1
example2.com. …

jozinko9
- 3
- 1