HTTPS and HTTP coexistence

iljitsch

Ars Tribunus Angusticlavius
9,637
Subscriptor++
(I had a hard time deciding where this needs to go: sever room forum? After all, it's about a web server. Networking forum? These are network protocols. But I landed here as HTML is explicitly on topic.)

So I decided to give in to peer pressure and finally enable HTTPS on my websites. These days, that's free and super easy with Let's Encrypt and certbot.

But now the conundrum: how do I handle the coexistence of HTTPS and HTTP? One reason I avoided HTTPS for so long is that it's another thing that can fail, and something that's only partially under my own control. So for that reason, I want everything to keep working as before over HTTP.

I have a bunch of subdomains for different areas of interest, but in order to not displease the web indexing gods, I always point to a single canonical location for each page, so many links aren't relative links, but they have the domain name in them. Turns out you can have protocol-relative URLs like //www.iljitsch.com/2020/keyboardtest/ (might as well plug my Javascript keyboard tester) so on an HTTP page this will be an HTTP link and on an HTTPS page an HTTPS link. This seems to be frowned upon these days because it's not enforcing all HTTPS all of the time, but other than that this should be fine, I think.

However, the web indexing gods are a fickle bunch, and they don't like duplicate content. You can avoid that by declaring one page canonical. So it might make sense to declare the HTTPS page canonical. But there's warnings all over the web against having the HTTP page declaring the HTTPS page canonical. I really don't understand that, what am I missing?

For dynamic content I might use a noindex meta tag on the HTTP version so Google and friends will ignore the HTTP version and just index the HTTPS version. However, most content is static so then that won't work.

One thing I learned as I was doing this: browsers (well, Safari and Chrome) no longer seem to care too much if you have HTTP elements on an HTTPS page, if those come from the same domain. The only thing that happens in this case is that you don't get the lock in the URL bar, but you also don't get the "not secure" warning that you get with HTTP pages.

If anyone has additional suggestions about handling HTTPS and HTTP I'm all ears.
 

minnmass

Ars Tribunus Militum
2,087
Subscriptor
Embrace HTTPS. It's a mature technology that has very little cost and tremendous upside, yes even for that one weird use-case (especially if it's a use-case on the public Internet).

Drop support for non-HTTPS. Time spent trying to make HTTP and HTTPS coexist is time wasted by actively working against best practices. Time spent trying to keep HTTP working is time wasted making it easier for malicious actors (and your visitors' ISPs) to inject JS (yes, there are still ISPs who inject bandwidth warnings on whatever random page you happen to be visiting), overwrite images, add/read cookies, etc. when your visitors visit your site.

Redirect HTTP traffic to HTTPS (use HSTS to help with that). Deprecate HTTP everywhere.

One reason I avoided HTTPS for so long is that it's another thing that can fail, and something that's only partially under my own control.

Ditto the web server (software), (virtual) web host (probably a VM), data center, 3rd party JS libraries, etc.. It's time to move to HTTPS.

I work on an eCommerce platform. The migration to HTTPS was a huge initiative (not least because the platform is multi-tenanted, with thousands of sites running on the same public IP address, so getting the certs to work right was a trick). There's always a window in which the cert isn't up yet for new sites; we've stopped working any bugs that start with "we don't have the cert yet, and we can't...".
 

iljitsch

Ars Tribunus Angusticlavius
9,637
Subscriptor++
Well, maybe in another 10 years, who knows. :)

I also never wanted to have anything to do with Javascript, but I now have a fair amount of it. (However, it's all optional, inline and doesn't block, so it doesn't slow things down.)

A few years ago when I had an actual job, we had long discussions about dropping support for older TLS versions. We really wanted/needed to, but there were still a few percent Android users who would then be left in the cold. And because everything was on HTTPS, there would be nowhere for them to go to learn about their misfortune and how to fix it.

So I really want to stay away from such issues for a few sites that are basically just blogs, with a few backend tools that let anyone search some publicly available data.

(But I guess my arguments to keep telnet enabled just in case something bad happens to ssh didn't stand the test of time, either...)

For one site I've set up redirects from HTTP to HTTPS, mostly to get Google to index the whole thing ASAP. I'm thinking of removing those redirects and just use noindex on the HTTP versions once Google is done indexing the HTTPS version of the site. However, that site is mostly dynamic so it's easy to implement redirects.

Another site has mostly static content. I guess I could get Apache to do the redirects, or perhaps just let de scripts that serve the home page and some other index pages do the redirect to HTTPS and then rely on HSTS.

I do remember an issue with HSTS with that previous job, but I can't remember what it was...

BTW, using a new URL scheme and a separate port for encryption was a really dumb decision. STARTTLS in SMTP is so much better.
 

iljitsch

Ars Tribunus Angusticlavius
9,637
Subscriptor++
something that's only partially under my own control
What do you mean by this?
If there's a problem with the certificate, I need to depend on the CA to get a new one ASAP.

Please note I'm not presenting my personal hesitations as ones that should apply universally, it's just that I want to take all of this nice and slow, which includes running HTTP and HTTPS side-by-side for an as yet undetermined amount of time.

I do want to stress that it's almost comical how easy all of this has gotten compared to me editing Apache SSL settings by hand a decade ago.

But I now do see some hits on domains that I didn't intend to HTTPS-enable, and that means a big fat "insecure" warning. There definitely are some details to investigate.
 

minnmass

Ars Tribunus Militum
2,087
Subscriptor
I'll just leave this handy link here, then: https://doesmysiteneedhttps.com/

... and this one: https://www.troyhunt.com/heres-why-your ... eds-https/

tl;dr for both: use HTTPS, deprecate HTTP; the only thing that should be happening on port 80 is a redirect to HTTPS.

Most web servers can issue redirects for all HTTP traffic, often with a wildcard for the path ("redirect your entire site to HTTPS with the one weird trick!"). For those that can't, a proxy can do so and the server can remain none the wiser.
 

kperrier

Ars Legatus Legionis
21,505
something that's only partially under my own control
What do you mean by this?
If there's a problem with the certificate, I need to depend on the CA to get a new one ASAP.
Is this worrying about something that almost never happens or have you had problems that automating Lets Encrypt certification updating doesn't solve?
 

iljitsch

Ars Tribunus Angusticlavius
9,637
Subscriptor++
No, this is all new to me. Other than some stuff with self-signed certificates many, many years ago, I'm now enabling HTTPS for the first time.

But if even a company like Apple can be caught flat footed with expired certificates, I really have a hard time going all-in within days after enabling it for the first time.

Please note that I have decided to have HTTPS and HTTP run side-by-side at this time, any efforts to convince me to go HTTPS-only in the near future are a waste of electrons...
 

kperrier

Ars Legatus Legionis
21,505
But if even a company like Apple can be caught flat footed with expired certificates, I really have a hard time going all-in within days after enabling it for the first time.
That is what the "automating Lets Encrypt certification updating" resolves. You schedule it in cron and the certs update automatically before they expire.
 

Lt_Storm

Ars Tribunus Angusticlavius
21,343
Subscriptor++
But now the conundrum: how do I handle the coexistence of HTTPS and HTTP? One reason I avoided HTTPS for so long is that it's another thing that can fail, and something that's only partially under my own control. So for that reason, I want everything to keep working as before over HTTP.

For the most part, you don't. Instead, redirects are a thing, so you set the HTTP version up to redirect to the HTTPS version and move on with life.

If you want to take it slow, pick one domain, set it up, and let it run for a while. Also, if you are worried about it failing, set something up to monitor it and let you know if the HTTPS isn't happy.
 

Pont

Ars Legatus Legionis
26,160
Subscriptor
If there's a problem with the certificate, I need to depend on the CA to get a new one ASAP.
And?

You're making an argument like "using authentication on my bank account is hard, and I don't want to have to remember a password and deal with the reset process".

There is an established profit motive for various actors to man-in-the-middle your website and alter the content your users are seeing. This is no longer theoretical. It doesn't matter if your website is a high-profile target or not, because they attack at a level that applies whether you're a 1-hit-per-month site or a top 5 site. Your DNS registration is not enough to protect your users from this kind of attack.

At best, your users will get annoying messages from their ISP. At worst, your website will have scripts injected that steal their passwords and/or use their computer to mine bitcoin.
 

Incarnate

Ars Tribunus Angusticlavius
9,037
Subscriptor++
Please note that I have decided to have HTTPS and HTTP run side-by-side at this time, any efforts to convince me to go HTTPS-only in the near future are a waste of electrons...
Are you posting from 2003? The best option, as others have said is to redirect all HTTP to HTTPS and be done with it. That will also solve your SEO issues.

If organizations as large as Amazon and Facebook can use it to run their businesses that are dependant on the sites being up 24/7/365, I think its proven enough for your use case. Nothing is going to cause a "problem with the certificate". It will work. Only concern should be not letting it expire, which you can solve by automating it. You can also setup alerting if the certificate expiration date gets closer than the automation date as a fallback if something goes wrong.

Seriously, if you are going to take such a hard line like "efforts to convince me to go HTTPS-only in the near future are a waste of electrons", then maybe its time to let someone else handle the technology.
 

iljitsch

Ars Tribunus Angusticlavius
9,637
Subscriptor++
If you want to take it slow, pick one domain, set it up, and let it run for a while.
I set it up for two domains, but that doesn't seem like the greatest idea ever, as the other domains running on the same IP address also get HTTPS hits but there is no valid certificate for those domains.

In the log I see a lot of bots seemingly upgrading HTTP URLs to HTTPS, as it's way too soon for them to learn about the new HTTPS URLs through crawling. Also, at least in one case when I typed a domain in Chrome it assumed HTTPS rather than HTTP.

So it's probably better to get a cert that covers all the (sub) domains that run on the same IP address.
 

Incarnate

Ars Tribunus Angusticlavius
9,037
Subscriptor++
Also, at least in one case when I typed a domain in Chrome it assumed HTTPS rather than HTTP
Chrome does that by default, so its not just in one case. Its in every case. You are actually causing slower load times for your visitors because it will try https first and then fall back to http when it doesn't respond. Any Chromium based browser, including Edge will try HTTPS first. Firefox also does the same in private browsing, an expect it will for all browser sessions shortly, so that covers the vast, vast majority of users visiting your site.
 

minnmass

Ars Tribunus Militum
2,087
Subscriptor
[url=http://www.iljitsch.com/2021/11-20-test-post-v2.html:df55y89s said:
iljitsch[/url]":df55y89s][protocol-relative URLs may be problematic because of cross-site scripting] But as I don't use any cross site scripting on iljitsch.com that's not an issue here.

You don't use cross-site scripting. HTTPS ensures that somebody else doesn't add any while the data's in flight (eg., the coffee shop's malware-ridden AP doesn't add anything).

HTTPS ensures that the bits your server sends out are the bits my browser receives. Without HTTPS, you have no guarantee that the bits your server sends aren't modified in-flight before my browser gets them. I might be tricked into using a malicious WiFi AP at a coffee shop and have all of the images on your site replaced with puppies (or things that are rather less cute) or a JS crypto miner. My ISP might inject usage warnings which may break your page. Heck: my ISP might inject ads.

[url=http://www.iljitsch.com/2021/11-20-test-post-v2.html:df55y89s said:
iljitsch[/url]":df55y89s]If you go HTTPS-only, ... you're cutting off some older systems and losing some performance.

There are a vanishingly small number of systems that HTTPS will necessarily cut off (and the number of things that those systems can do is dwindling quickly, anyway), and the performance hit for HTTPS is paltry. In fact, HTTPS allows for HTTP/2 and multiplexing, so the user might actually feel a speed-up.
 

iljitsch

Ars Tribunus Angusticlavius
9,637
Subscriptor++
[url=http://www.iljitsch.com/2021/11-20-test-post-v2.html:18bpzhpi said:
iljitsch[/url]":18bpzhpi]If you go HTTPS-only, ... you're cutting off some older systems and losing some performance.
There are a vanishingly small number of systems that HTTPS will necessarily cut off (and the number of things that those systems can do is dwindling quickly, anyway), and the performance hit for HTTPS is paltry.
I fired up my old Amiga 1200 the other day and HTTPS worked well (the 2000px+ wide images less so). The time between typing the URL and the page starting to show was pretty long but not sure it was much faster over HTTP. The image loading seemed a bit faster over HTTP, but nothing spectacular. However, this is with about the fastest 68k CPU Motorola ever built and with recent software.

In fact, HTTPS allows for HTTP/2 and multiplexing, so the user might actually feel a speed-up.
Well, I enabled HTTPS so feel free to use that. Still need to look into supporting HTTP/2, though. One thing at a time.

Interesting to see that Google's spider is randomly using / not using HTTPS but no HTTPS showing up in search engine results yet after two days.
 

Ardax

Ars Legatus Legionis
19,794
Subscriptor
I'm thinking they try HTTPS but fall back to HTTP if there is a certificate problem. Not going to go out of my way to test that, though.
If there's a cert problem, every browser WILL balk and show an error to the user, NOT silently fall back to HTTP.

Unencrypted HTTP is rapidly going the way of unencrypted FTP. The only reason it's taking so long is because HTTP is used more than FTP.
 

Lt_Storm

Ars Tribunus Angusticlavius
21,343
Subscriptor++
I'm thinking they try HTTPS but fall back to HTTP if there is a certificate problem. Not going to go out of my way to test that, though.
If there's a cert problem, every browser WILL balk and show an error to the user, NOT silently fall back to HTTP.

Which, of course, is necessary for security. I mean, if they didn't, then someone who was MITMing you could give a bad cert and let you connect to them on HTTP.
 

sryan2k1

Ars Legatus Legionis
46,877
Subscriptor++
You can, but you shouldn't. It's best practice for each service to have it's own cert, and when using something like LE, there is literally no reason to make security worse.


Yes, so let's see that work correctly a few times.


You can force a renewal if you want, but the whole point of certbot (or whatever your ACME client is) running daily is that typically it starts to try to renew at 30 days and that gives you 30 days of it failing to fix any issues before something bad happens. Millions of certs come from LE, this isn't an issue.


We run our own internal ACME PKI and our certs are only valid for 7 days.
 

minnmass

Ars Tribunus Militum
2,087
Subscriptor
You can force a renewal if you want, but the whole point of certbot (or whatever your ACME client is) running daily is that typically it starts to try to renew at 30 days and that gives you 30 days of it failing to fix any issues before something bad happens. Millions of certs come from LE, this isn't an issue.

In agreeance...

We run a multi-tenanted web app (thousands of websites behind a single IP address, with the per-site domains occasionally shifting because customers). Mostly for that reason (and being an MS-heavy shop), we have a home-grown service that pushes LE certs to a non-home-grown SSL termination service (it's a major one).

:eng101: Pro tip: if you have to do this, run an internal validation before having LE run its validation; cuts way down on error-based throttling when a customer adds a new domain to their site but neglects to buy the domain or point it to the right IP address. Yes, we'll do this for our customers, and I think we just charge them the actual cost of the domain name. Yes, customers still insist on doing it themselves. o_O

In the ... 3 years? ... we've been using LE, I can count on one hand the number of times LE's been the problem when a cert creation/renewal hiccups (and if I had a nickel for every time a customer added a domain they didn't actually own or have pointed right, I'd have my own space program).

~3 years, call it 5k sites, 60 day renewal start ~= 90k certs created/renewed. 5 failures because of LE (which I think is high) comes out to ~0.000056% failure rate. Even if LE's error rate is 1000x bigger (and the difference is hiding in the 30 day renewal window), that's still just an 0.056% error rate. Not half a percent, half of a tenth of a percent.

It's definitely worth some due-diligence when starting up, making sure the ACME client and webserver(s) are configured correctly, but that should be a couple of days (ideally on a test environment) for most purposes.

Heck: Wikipedia uses LE certs and apparently, Shopify uses them for customer sites; they're not just for fly-by-night operations, and using them isn't going to be the problem.