Skip to content

[configuration] only perform replacement on resources which content type is text #40

@IceCodeNew

Description

@IceCodeNew

My ISP blocks the site mikanani.me, and I am trying to set up a reverse proxy for it. Thanks for this great project; I managed to make it work.
Based on a working configuration, I took a step further to lower the memory consumption so this mirror site could handle a crowd of users. And that is where I came into a problem.
The only change between a working configuration and a broken one is to enable a response matcher. But no matter how hard I tried, I couldn't understand what happened. Any information would be appreciated.

The site being proxied is very simple, and there are no third-party resources to be loaded (except for its site icon): https://mikanani.me/RSS/Bangumi?bangumiId=3598&subgroupid=370
And here is the minimum reproducible bad configuration of my mirror site. No replacement performed with that configuration.

# broken configuration
{
	admin off
	debug
	storage file_system /usr/local/etc/caddy/
}

(extendable-proxy) {
	route {
		@text_content {
			header Content-Type application/javascript*
			header Content-Type application/json*
			header Content-Type application/xml*
			header Content-Type text/*
		}

		encode
		replace @text_content stream {
			{args[0]} {args[1]}
		}

		reverse_proxy https://{args[0]} {
			header_up Accept-Encoding identity
			header_up Host {upstream_hostport}
			header_up -X-Forwarded-*
			header_down Location {args[0]} {args[1]}
		}
	}
}

import sites-enabled/*

# sites-enabled/rp-to-mikan
aaa.example.com {
	import extendable-proxy mikanani.me aaa.example.com
}
# working configuration
- 		@text_content {
- 			header Content-Type application/javascript*
- 			header Content-Type application/json*
- 			header Content-Type application/xml*
- 			header Content-Type text/*
- 		}

		encode
- 		replace @text_content stream {
+ 		replace stream {
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions