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.

720 questions
0
votes
0 answers

Fail2ban make a custom fail regex filter for Nginx error log

I am new to regex. How do I write a Fail2Ban filter to match with these nxinx error log lines? 2022/11/30 00:46:19 [crit] 57811#57811: *8911 SSL_do_handshake() failed (SSL: error:141CF06C:SSL routines:tls_parse_ctos_key_share:bad key share) while…
0
votes
1 answer

Regexp header_checks in postfix for a match over multiple lines

Here's my /etc/postfix/main.cf header_checks line: header_checks = regexp:/etc/postfix/maps/header_checks And here is header_checks: /From:.*email@my\.com.(\n|.)*?To:.*email@my\.com./ DISCARD Here's portion of the header from the emails I'm…
Denny
  • 1
0
votes
1 answer

Implementing arithmetic rules in sieve to filter recipient address, is it possible?

For example, the receiver's address should have the following pattern: last digit = (1st digit + 2nd digit)%10. abc123@testdomain.com, PASS, 1+2=3, and the last digit is 3. abc124@testdomain.com, FAIL, 1+2=3, but the last digit is…
stackname
  • 1
  • 1
0
votes
1 answer

Playbook to extract hosts from /etc/hosts

I need help extracting hosts informations from /etc/hosts file and exporting that content to a predefined file. I created a Ansible's Playbook to this task, but the content is not written on the output file. Do you guys, can help me,…
0
votes
0 answers

Regular expression for url longer than 3 characters Nginx

There is a website site.ru/ I need to write a regular expression where pages longer than 3 characters only work after the first slash. If in this case there are other pages after the slash, then 404 was returned. For example site.ru/demo ->…
All In
  • 1
  • 1
0
votes
1 answer

Nginx: try_fiiles directive with variable from path

I have set up a server block that looks like this: root /var/www/platform location / { index index.html; } location /contact { try_files $uri /contact.html; } This works fine. I can go to x.com/contact and the contact.html page loads. Now I…
ahron
  • 365
  • 3
  • 14
0
votes
0 answers

Remove country code from url in Nginx

I need to configure the replacement of the URL containing the country code (code length is always 2 characters). Example: https://example.ru/en/ => https://example.ru https://example.ru/en/info/ =>…
0
votes
1 answer

How to properly manage Ansible regex for network device

I'm currently testing to retrieve firmware version lists on HP/Aruba switches using arubanetworks.aos_switch collection. Basically i'm just doing : collections: - arubanetworks.aos_switch tasks: - name: Launching "show flash" CLI …
motorbass
  • 303
  • 2
  • 12
0
votes
1 answer

NGINX: Location matches assests

I'm having issues where my location is matching a resource one server should be serving because it has the some format as a directory With this configuration: location ~ "/web/" { set $upstream_host http://webServer; set $upstream_port…
0
votes
1 answer

How to disable cache for some subpath nginx

I try to create a microcaching in Nginx by configuring that only valid for the subpath of some URI that will work. For example : https://example.com/path/anotherpath/view/ --> Will be cached https://example.com/path/anotherpath/view/subview --> not…
navotera
  • 101
  • 5
0
votes
1 answer

Remove bunch of disconnected LUNs by shell script (regex issue)

Have a problem with my script, don't want to run same procedure 200 times with changing LUN number. Remove the multipath device from ALL paths to the LUN, run echo 1 > /sys/bus/scsi/devices/${H:B:T:L}/delete (Where H = host:B = bus:T = target:L =…
flexman
  • 1
  • 1
0
votes
1 answer

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 / HTTP/1.0" 400 0 "-" "-" So, this is my fail2ban custom…
spacecodeur
  • 107
  • 4
0
votes
1 answer

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] RewriteRule ^/app\.jsp$ /app/%2?%1%3 [R=302] ... to rewrite…
user27772
  • 111
  • 2
0
votes
1 answer

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 this code. What is the function of each special letter in…
TRONG NGUYEN
  • 3
  • 1
  • 4
0
votes
1 answer

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 = ^%(_apache_error_client)s…
dan
  • 83
  • 1
  • 7