corazawaf / coraza-caddy

OWASP Coraza middleware for Caddy. It provides Web Application Firewall capabilities
https://www.coraza.io/
Apache License 2.0
290 stars 35 forks source link

Spurious "failed to parse server name" messages #70

Closed ericswpark closed 1 year ago

ericswpark commented 1 year ago

I'm getting the following line in my logs when I access my sites:

{"level":"warn","ts":1686448129.858539,"logger":"http.handlers.waf","msg":"failed to parse server name","tx_id":"_______________","error":"failed to parse server name from authority \"sub.example.com\", address sub.example.com: missing port in address"}

I've noticed that some sites work perfectly fine with this warning while other sites will just throw up a blank page with a 200 response code. (Edit: warning message not indicative of this problem)

Should I be worried about this warning? Is there a way to fix it?

Here is a part of my Caddyfile:

sub.example.com {
    reverse_proxy 127.0.0.1:1642

    coraza_waf {
        load_owasp_crs
        directives `
            Include @coraza.conf-recommended
            Include @crs-setup.conf.example
            Include @owasp_crs/*.conf
            SecRuleEngine On
        `
    }
}
jcchavezs commented 1 year ago

I think maybe it is a good idea to remove the warning and use that domain as serverName as it will be super repetitive cc @M4tteoP

On Sun, 11 Jun 2023, 03:52 Eric Park, @.***> wrote:

I'm getting the following line in my logs when I access my sites:

{"level":"warn","ts":1686448129.858539,"logger":"http.handlers.waf","msg":"failed to parse server name","tx_id":"___","error":"failed to parse server name from authority \"sub.example.com\", address sub.example.com: missing port in address"}

I've noticed that some sites work perfectly fine with this warning while other sites will just throw up a blank page with a 200 response code.

Should I be worried about this warning? Is there a way to fix it?

— Reply to this email directly, view it on GitHub https://github.com/corazawaf/coraza-caddy/issues/70, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAXOYASYWRZNAZ66ODIEALTXKUQETANCNFSM6AAAAAAZCAPUPI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

ericswpark commented 1 year ago

It seems like this warning message is not indicative of problems with using Coraza with some services I reverse-proxy to. I'll edit this post accordingly and create a separate bug report.

Aljutor commented 1 year ago

I build caddy today as

    --with github.com/corazawaf/coraza-caddy@main \
    --with github.com/corazawaf/coraza-coreruleset"

but still there are plenty of messages with"logger":"http.handlers.waf","msg":"failed to parse server name"

jcchavezs commented 1 year ago

Try latest commit. Parsing of server should not fail anymore as per https://github.com/corazawaf/coraza-caddy/pull/72

Aljutor commented 1 year ago

Not sure how to build it properly with xcaddy

xcaddy build \
    --with github.com/caddy-dns/cloudflare \
    --with github.com/caddyserver/transform-encoder \
    --with github.com/corazawaf/coraza-caddy@61bb4b1 \
    --with github.com/corazawaf/coraza-coreruleset"
[INFO] exec (timeout=0s): /usr/bin/go get -d -v github.com/corazawaf/coraza-caddy@61bb4b1 
github.com/caddyserver/caddy/v2@cbf16f6 ", "go: github.com/corazawaf/coraza-caddy@61bb4b1:
github.com/corazawaf/coraza-caddy@v1.2.3-0.20230611210624-61bb4b1be56e: invalid version: 
go.mod has post-v1 module path \"github.com/corazawaf/coraza-caddy/v2\" at revision 61bb4b1be56e"
ericswpark commented 1 year ago

@Aljutor try using @master

Aljutor commented 1 year ago

With @master or @main I still see "logger":"http.handlers.waf","msg":"failed to parse server name" Some shenanigans with versioning perhaps.

jcchavezs commented 1 year ago

Try latest commit. Parsing of server should not fail anymore as per https://github.com/corazawaf/coraza-caddy/pull/72.

Also use github.com/corazawaf/coraza-caddy/v2@61bb4b1 and finally you don't need to include coraza-coreruleset.

andreground commented 1 month ago

Hi,

I'm on the latest build and still I get a lot of these warnings.

Caddy v2.8.4 coraza-caddy@master

{ "directives": "SecRuleEngine On", "handler": "waf", "include": [ "@coraza.conf-recommended", "@crs-setup.conf.example", "@owasp_crs/*.conf" ], "load_owasp_crs": true }

Am I missing something?

Thanks