Reverse proxy for Instagram/tumblr etc

I try to reverse proxy for Instagram

ins.example.com:443 {
gzip
tls /etc/ssl/z.crt /etc/ssl/z.key
proxy / https://www.instagram.com/ {
transparent
header_upstream Host {host}
header_upstream X-Real-IP {remote}
header_upstream X-Forwarded-For {host}
header_upstream X-Forwarded-Proto {scheme}
}
}

However, when visiting https://ins.example.com, it was found that Instagram’s image address is https:// .cdninstagram.com
If you want to reverse proxy this address, and modify the returned image address in ins.example.com
How to configure it?

After trying, I still failed
/docs/rewrite
/docs/redir

Thanks a lot

I have tried to build multiple reverse proxy
But did not find how to replace the https://abc.cdninstagram.com 's domain to inscdn.example.com set Caddyfile

Since you want to modify the response body coming back from the upstream server before sending it on to the original client, you want to look into using https://caddyserver.com/docs/http.filter.

You could use it to change all instances of one domain in the response body to another domain instead, such as the CDN domain you want to use.

1 Like

http.filter (as @Whitestrake mentioned) works well for this. I have a github proxy with a config like this:

https://github.example.com {
    filter rule {
        content_type text/html.*
        search_pattern assets-cdn.github.com
        replacement assets.example.com
    }

    proxy / https://github.com {
        header_downstream -Content-Security-Policy
        header_downstream -Strict-Transport-Security
        header_downstream -Public-Key-Pins
        header_downstream -X-XSS-Protection
    }
}

https://assets.example.com {
    proxy / https://assets-cdn.github.com {
        header_downstream -Content-Security-Policy
        header_downstream -Strict-Transport-Security
        header_downstream -Public-Key-Pins
        header_downstream -X-XSS-Protection
    }
}

Login to github doesn’t work, however, as 302 redirects are not rewritten.

2 Likes

Thank you very much :grin:

Thank you for sharing :grin:

This service provides proxis and accounts for instagram Buy Unfollows for your Instagram | Zen Promo Unfollow App. And there’re analytic tools and yadayada

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