Assuming that you’re serving the same site and scheme is the only thing that changes for /nosslpath. Otherwise, if separate handling is required, split the top two labels into their own site blocks.
I have a legacy backend and a legacy iOS app which I can not touch anymore. The legacy app consumes an XML file provided by said URL and it must be non-SSL. One of the customer consumes another URL of the web frontend in an iFrame on a new, SSL-secured website and faces a “Mixed content” error, if this URL is not provided as SSL. I still need it for a couple of weeks until the new solution will be ready
Thank you very much for your help. Unfortunately it does not work. I did try it your way and the opposite way (upgrade a particular URL to SSL and leave the rest unsecured), in any case the extra ULR does not work, either I get a 404 or a fallback page. But if the complete site is non-SSL, everything works fine.
Definitely check browser cache, because this method definitely works.
It seems like you don’t need to explicitly downgrade clients, so I left that part out, but here is a live working concept. Effectively what we’re doing is accepting HTTPS across the board for simplicity, but allowing HTTP requests for the endpoints specified.
whitestrake at ishtar in /docker/web
→ cat caddyfiles/nosslpath.whitestrake.net.caddy
https://nosslpath.whitestrake.net, http://nosslpath.whitestrake.net/nossl, http://nosslpath.whitestrake.net/alsonossl {
status 200 /
}
# Upgrade normal HTTP requests
http://nosslpath.whitestrake.net {
redir https://{host}{uri}
}
As you can see, you can add more “upgrade-exempt” locations just by adding them to the label list.
Here’s the result:
whitestrake at apollo in ~/.dotfiles on master [!]
→ curl -I nosslpath.whitestrake.net
HTTP/1.1 301 Moved Permanently
Location: https://nosslpath.whitestrake.net/
Server: Caddy
Date: Sun, 28 Jan 2018 21:41:39 GMT
Content-Type: text/plain; charset=utf-8
whitestrake at apollo in ~/.dotfiles on master [!]
→ curl -I nosslpath.whitestrake.net/nossl
HTTP/1.1 200 OK
Server: Caddy
Date: Sun, 28 Jan 2018 21:41:47 GMT
Content-Type: text/plain; charset=utf-8
whitestrake at apollo in ~/.dotfiles on master [!]
→ curl -I nosslpath.whitestrake.net/alsonossl
HTTP/1.1 200 OK
Server: Caddy
Date: Sun, 28 Jan 2018 21:41:53 GMT
Content-Type: text/plain; charset=utf-8
Feel free to check for yourself - the URLs in the above snippets are live and I’ll leave them up for a while, it just serves empty Status 200’s to prove the concept, but it’ll definitely work for a proxy too.
Thank you very much, I can see that it works. However, in my case the URL my backend receives must be somehow different than the one it receives, when I set the complete site to SSL off.
According to my console log, the Caddy creates the following GET request URL when SSL is completely turned off: http://www.whitehouse.twanda.ch/winelist/
This works perfectly for my backend.
Using your suggestion, I assume that the URL must be something different, as the backend forwards it to a fallback URL.
By the way, my backend is tomcat6.
Is it possible that this is correlated with the “302 found” message I get in the console?
With a Host: www.whitehouse.twanda.ch request header
(along with some other headers too)
Over a HTTP connection
To the listener at 192.168.xxx.xxx:8080.
The Host header sent to the backend is lifted from the host requested by Caddy’s client.
I note that the transparent preset includes header_upstream X-Forwarded-Proto {scheme}. As far as I’m aware, this is the only method the backend can use to detect whether or not the original client connected via HTTP or HTTPS.
Whatever the backend is, it should be configured not to issue conflicting redirects. Given that it’s on an internal network, it might suffice to have it be totally permissive with respect to protocol.