Basicauth and fastcgi

I’m trying to use basicauth to authenticate before loading my php application.

Here are the relevant lines from the Caddyfile:

basicauth / user pass

fastcgi / localhost:9000 php
rewrite {
  if {path} ends_with /
  to {dir}/index.html {dir}/index.php /_h5ai/public/index.php

But when I request a page, it simply loads, same as if I removed the basicauth line. basicauth works as expected if I take out the fastcgi and rewrite directives.

How do I configure these two features to work together?


In other news, Caddy rocks!

I havent tested it myself but your config looks good.

However I once had a problem with special characters ($,!,/, etc). Try adding quotes to your basicauth directive like:

basicauth / "user" "pass"

That made it work for me.

That’s strange, quotes should only be necessary when there is whitespace in the value.

Your Caddyfile works just fine for me. Maybe clear your cache or something?

Ok, I’ll retest that in a minute it may have been a different problem.

Just tested it. Without the quotes it does ask for authentication but wont let me in with the correct password.

Oh, I just noticed why. My password contains a #. I guess that is getting parsed as a comment. :wink:

Oops, yep, whitespace and comments.

I don’t know what stupid thing I was doing with my browser but I tried it again and it worked.

Thanks y’all!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.