-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fastcgi: Add new php_fastcgi
subdirectives to override shortcut behaviour
#3255
Conversation
5bf10fa
to
562befb
Compare
I was reading through the codebase some more and I realized there's a better approach than adding 2 new funcs to Dispenser to manipulate the cursor. I'm pretty sure I can use I'll refactor this soon. Edit: Done |
562befb
to
ed01ff1
Compare
ed01ff1
to
935f8a3
Compare
php_fastcgi
subdirectives to override shortcut behaviour
@francislavoie When you get a chance, could you fix the merge conflict? Then I'll do a final review. Looking good though. Note that I'll be relying on you for fixes to any potential bug reports that come in related to this in the future 😅 (esp. since I don't really have a PHP environment!) Thanks! |
Yep, this one will need a bit of reworking actually, because of the |
Gotcha... no hurry. I can see the huge value in this though. Thanks! |
8a4bad3
to
9c4592f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this! It'll be super useful.
I haven't verified that all the hidden/implicit route logic was brought over correctly, but I trust that it works.
Just a couple minor nits -- nothing showstopping though. Would be nice if a few more people with actual PHP environments could test this out first?
9c4592f
to
82ba899
Compare
82ba899
to
89de0fc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Code looks nice, I'll assume it works. Anyone with a PHP environment could please test it out, thank you!
The php_fastcgi Caddyfile directive acts as a shortcut to a quite long expanded form. There are many situations where users might want to override some of the behaviour generated by the shortcut.
This change makes it possible to override some aspects of the shortcut by first reading the subdirective block once, handling any subdirectives that are relevant, and importantly, deleting the tokens as it goes. Then, it rewinds the Dispenser's cursor to the point just before so that the
reverse_proxy
's UnmarshalCaddyfile can read it for itself. We delete as we go, because otherwise thedefault:
case inreverse_proxy
would returnd.Errf("unrecognized subdirective %s", d.Val())
.Adds the following subdirectives:
split
: passthrough to thesplit_path
subdirective of thefastcgi
transport, but also affects the path matcher for the list of PHP file extensions to supportenv
: passthrough to theenv
subdirective of thefastcgi
transportroot
: passthrough to theroot
subdirective of thefastcgi
transportindex
: defaults toindex.php
, controls the file that is used as atry_files
fallback. If the value is set tooff
, it disables the path canonicalization redirect and thetry_files
rewrite altogether.Caddyfile:
JSON output: