-
Notifications
You must be signed in to change notification settings - Fork 27
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
placeholders not support {http.request.host} #26
Comments
Please share your full config. Show an example request with |
Actually, I have a site deployed to cloudflare. Caddy --version:
Caddyfile:
|
We also need your logs (enable the It's important. Whether it works or not depends on how your upstream responds. |
sure, I created a test.html and content is 'Aexample.com' for show the "curl -v" curl -v https://testsub.Bexample.com/clients/test.html
the last line is: {http.request.host} |
Is your backend compressing the response (does it support gzip compression)? If so, the replacer can't operate on compressed payloads... |
@mholt @francislavoie I was able to confirm this issue as well using a simple NodeJS backend for testing: const http = require("http");
const server = http.createServer((req, res, next) => {
console.log(req.url);
console.log(req.rawHeaders);
res.writeHead(200);
res.write("This is a test", "utf8");
res.end();
});
server.listen(process.argv[2]); $ node index.js 8181 Using the following Caddyfile:
Responses are rewritten when using a string with the replacement handler: curl https://localhost:8443 -v
* Trying 127.0.0.1:8443...
* Connected to localhost (127.0.0.1) port 8443 (#0)
* ALPN: offers h2
* ALPN: offers http/1.1
* CAfile: /etc/pki/tls/certs/ca-bundle.crt
* CApath: none
< HTTP/2 200
< alt-svc: h3=":8443"; ma=2592000
< date: Tue, 16 Apr 2024 19:08:36 GMT
< server: Caddy
<
This is a I was replaced% However when using placeholder Caddyfile:
Response: curl https://localhost:8443 -v
* Trying 127.0.0.1:8443...
* Connected to localhost (127.0.0.1) port 8443 (#0)
* ALPN: offers h2
* ALPN: offers http/1.1
* CAfile: /etc/pki/tls/certs/ca-bundle.crt
* CApath: none
< HTTP/2 200
< alt-svc: h3=":8443"; ma=2592000
< date: Tue, 16 Apr 2024 19:09:57 GMT
< server: Caddy
<
This is a {http.request.host}% |
Oh, you know, this is because, for efficiency reasons, we allocate the transformer chain at Provision-time instead of Request-time. So there is no I don't know for sure, but @icholy's excellent There is no |
Great! Looking forward to seeing what can be done. In our use case, we don't always know what the replacement value should be since we support many vhosts, so being able to dynamically replace would be amazing. |
Hello, I'm trying to replace ngcspnonce in an angular app with this module as well as https://github.com/luludotdev/caddy-requestid so that it's a different nonce on every request. In the header the caddy-requestid module is correctly setting the nonce, but when I try to replace it using this module, it's replacing the string with the string literal. Am I correct in assuming this is because of the same issue here? My Caddyfile:
|
Hi,
I have a generic domain name and would like to use the replace-response to reach the replacement of the real domain name requested by the user. But always replace by text:{http.request.host}
As in the following configuration file:
Is there any way to make it happen? Thanks!
The text was updated successfully, but these errors were encountered: