Skip to content
This repository has been archived by the owner on Mar 1, 2023. It is now read-only.

parameter path and content_type "or" combined instead of expected "and" #20

Closed
Stonedestroyer opened this issue Jul 25, 2017 · 8 comments
Assignees
Milestone

Comments

@Stonedestroyer
Copy link

Hello, I am using your plugin.

I got caddy version 0.10.4 and your plugin build as of today from the caddy build servers.

	filter rule {
		path /tixati
		content_type text/html
		search_pattern ="/
		replacement ="/tixati/
	}

This replaces all of ="/ it can find on any path. It does not seem to respect the path. We tried with $/tixati as well but there was no difference.
Discussion here https://caddy.community/t/reverse-proxy-rewriting/2393/17 about the issue.

@blaubaer blaubaer self-assigned this Aug 12, 2017
@blaubaer blaubaer added the bug label Aug 12, 2017
@blaubaer
Copy link
Member

I will try to reproduce this with an integration test as soon as possible.

@blaubaer
Copy link
Member

I got your problem. Currently path and content_type are or combined not and - I will change this because this is unexpected behaviour.

@blaubaer blaubaer changed the title Issue with path parameter path and content_type "or" combined instead of expected "and" Aug 13, 2017
@blaubaer blaubaer added this to the 0.8 milestone Aug 13, 2017
blaubaer added a commit that referenced this issue Aug 13, 2017
…le to decide if the user wants `and`/`or` and set it by default to `and`.
@blaubaer blaubaer added enhancement and removed bug labels Aug 13, 2017
blaubaer added a commit that referenced this issue Aug 13, 2017
…le to decide if the user wants `and`/`or` and set it by default to `and`.
@Stonedestroyer
Copy link
Author

I think this change broke the plugin. It seems no replacement rules work for me, neither the example ones.

@sheriff
Copy link

sheriff commented Aug 22, 2017

I'm not sure if I have the same issue (or related to #2) but I can't get the plugin to rewrite content when the path is also being served with the proxy plugin. I'm using the latest binary and plugins from the build server (caddy v0.10.6, http.filter v0.9)

I had the same issue with content_type always matching, regardless of path, so I removed the content_type directive completely. However, now it doesn't match and rewrite at all.

proxy /http https://httpbin.org {
  try_duration 2s
  without /http
}
filter rule {
  path ^/http
  search_pattern href="/([^"]+)"
  replacement href="/http/{1}"
}

@blaubaer
Copy link
Member

@Stonedestroyer Could you please provide a simple Caddyfile with corresponding HTML-file and the request you did to the server - which enables me to 100% to reproduce the issue? Thanks!

@Stonedestroyer
Copy link
Author

That's strange a completely new caddyfile works.

domainname {
    root C:\dir
	ext .html
    filter rule {
    	path .*\.html
		search_pattern replaceme
		replacement fails
	}
}

and .html file with replaceme in it.

I can confirm proxy does not work which is probably what both of them were.

@blaubaer
Copy link
Member

@Stonedestroyer: The file above looks broken?

@Stonedestroyer
Copy link
Author

Stonedestroyer commented Aug 22, 2017

I just created a .html file with replaceme in it that worked. I think it's just the proxy directive with the filter. As that is what worked before when it replaced my proxy called Tixati. So I am not completely sure what to give you, I am gonna try setup a test with quick proxy and replace. Will try it with xampp + caddy.

I make sure to give you all the files. The test above works.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

3 participants