问题原文
原帖链接 · nicolasochem · CC BY-SA 4.0
I am running a small static website in a google storage bucket.
I have http and https support.
But I want http to redirect to https, so no visitor ends up with the "not secure" browser warning.
There is no way to do that with a google storage bucket (yet?) so the easiest way is to set up a Cloudflare proxy in front of it.
But an equally simple solution would be to turn off http completely, so nothing listens on port 80.
What are the downsides of doing so ? In this day and age, any decent browser would attempt to connect to https directly, right ?
已采纳解答
原帖链接 · Caius Jard · CC BY-SA 4.0
In this day and age, HTTP is still the default protocol if the user types something into the address bar and doesn't specify a protocol at all. Most webmasters that want their users to only use HTTPS will leverage some redirect mechanism of the webserver, to receive the requested HTTP URL and convert it to HTTPS, then issue a redirect response to the user saying "got your request to access http://server.example/some/path?and=query, but this document has been moved to https://server.example/some/path?and=query". URL rewrite modules are a popular way to achieve this, but some servers may have a simple setting to push all HTTP requests to HTTPS. In other cases the application code of the site might do the redirecting
If you have full control of how the user gets these links then you can make sure that you only ever issue HTTPS links and the user is never aware that there is no HTTP version. For example if the user is using your website and you're listing files for download, you make sure the page they see only has HTTPS links on it; they'll never right click, copy, paste, remove the S, and try to access over HTTP (or if they do they shouldn't be surprised that it doesn't work)...
..but you probably do at least want a way for anyone typing your website into a browser to get to the main home page, to not have to type HTTPS as well, and for that purpose you use some kind of mechanism that will receive the request on HTTP and redirect to HTTPS
It's perfectly possible to run a website on any port, with any protocol. You can have just HTTPS on 443, or HTTP on 12380 and HTTPS on 55443. You could even have HTTPS on 80 and HTTP on 443; the browser doesn't look at the port number when deciding the protocol (it has some default ports built in that it infers from the protocol) but if you were to arrange such a weird situation then the users would have to type https://server.example:80 which would be quite confusing - make all this as easy as possible
As such, to answer the question, yes you can run just an HTTPS site, but you really should run an HTTP site to make it easy for anyone who might happen to type yoursite.example into a browser, press return and expect to reach your site. Once you have them you can send them links of any protocol and port and they'll just use them, but make that first onboarding step as easy as possible, probably by employing a redirect to HTTPS
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
