Enabling HTTPS on your servers  |  Articles  |  web.dev (2024)

Enabling HTTPS on your servers | Articles | web.dev (1)

Chris Palmer

Matt Gaunt

Steps covered in this article

  1. Create a 2048-bit RSA public/private key pair.
  2. Generate a certificate signing request (CSR) that embeds your public key.
  3. Share your CSR with your Certificate Authority (CA) to receive a finalcertificate or a certificate chain.
  4. Install your final certificate in a non-web-accessible place such as/etc/ssl (Linux and Unix) or wherever IIS requires it (Windows).

Generating keys and certificate signing requests

This section uses the openssl command-line program, which comes with mostLinux, BSD, and Mac OS X systems, to generate private/public keys and a CSR.

Generate a public/private key pair

Let's start by generating a 2,048-bit RSA key pair. A smaller key, suchas 1,024 bits, is insufficiently resistant to brute-force guessing attacks. Alarger key, such as 4,096 bits, is overkill. Over time, key sizes increase ascomputer processing gets cheaper. 2,048 is currently the sweet spot.

The command to generate the RSA key pair is:

openssl genrsa -out www.example.com.key 2048

This gives the following output:

Generating RSA private key, 2048 bit long modulus.+++.......................................................................................+++e is 65537 (0x10001)

Generate a certificate signing request

In this step, you embed your public key and information about your organizationand your website into a certificate signing request or CSR. The opensslcommand interactively asks you for the required metadata.

Running the following command:

openssl req -new -sha256 -key www.example.com.key -out www.example.com.csr

Outputs the following:

You are about to be asked to enter information that will be incorporatedinto your certificate requestWhat you are about to enter is what is called a Distinguished Name or a DN.There are quite a few fields but you can leave some blankFor some fields there will be a default value,If you enter '.', the field will be left blank.-----Country Name (2 letter code) [AU]:CAState or Province Name (full name) [Some-State]:CaliforniaLocality Name (for example, city) []:Mountain ViewOrganization Name (for example, company) [Internet Widgits Pty Ltd]:Example, Inc.Organizational Unit Name (for example, section) []:Webmaster Help Center ExampleTeamCommon Name (e.g. server FQDN or YOUR name) []:www.example.comEmail Address []:webmaster@example.comPlease enter the following 'extra' attributesto be sent with your certificate requestA challenge password []:An optional company name []:

To ensure the validity of the CSR, run this command:

openssl req -text -in www.example.com.csr -noout

And the response should look like this:

Certificate Request: Data: Version: 0 (0x0) Subject: C=CA, ST=California, L=Mountain View, O=Google, Inc.,OU=Webmaster Help Center Example Team,CN=www.example.com/emailAddress=webmaster@example.com Subject Public Key Info: Public Key Algorithm: rsaEncryption Public-Key: (2048 bit) Modulus: 00:ad:fc:58:e0:da:f2:0b:73:51:93:29:a5:d3:9e: f8:f1:14:13:64:cc:e0:bc:be:26:5d:04:e1:58:dc: ... Exponent: 65537 (0x10001) Attributes: a0:00 Signature Algorithm: sha256WithRSAEncryption 5f:05:f3:71:d5:f7:b7:b6:dc:17:cc:88:03:b8:87:29:f6:87: 2f:7f:00:49:08:0a:20:41:0b:70:03:04:7d:94:af:69:3d:f4: ...

Submit your CSR to a certificate authority

Different certificate authorities (CAs) require different methods for sendingthem your CSRs. Methods may include using a form on their website, sending theCSR by email, or something else. Some CAs (or their resellers) may even automatesome or all of the process (including, in some cases, key pair and CSRgeneration).

Send the CSR to your CA, and follow their instructions to receive your finalcertificate or certificate chain.

Different CAs charge different amounts of money for the service of vouchingfor your public key.

There are also options for mapping your key to more than one DNS name, includingseveral distinct names (e.g. all of example.com, www.example.com, example.net,and www.example.net) or "wildcard" names such as *.example.com.

For example, one CA currently offers these prices:

  • Standard: $16/year, valid for example.com and www.example.com.
  • Wildcard: $150/year, valid for example.com and *.example.com.

At these prices, wildcard certificates are economical when you have more than 9subdomains; otherwise, you can just buy one or more single-name certificates. (Ifyou have more than, say, five subdomains, you might find a wildcard certificatemore convenient when you come to enable HTTPS on your servers.)

Copy the certificates to all your front-end servers in a non-web-accessibleplace such as /etc/ssl (Linux and Unix) or wherever IIS (Windows) requiresthem.

Enable HTTPS on your servers

Enabling HTTPS on your servers is a critical step in providing security foryour web pages.

  • Use Mozilla's Server Configuration tool to set up your server for HTTPS support.
  • Regularly test your site with the Qualys' handy SSL Server Test and ensureyou get at least an A or A+.

At this point, you must make a crucial operations decision. Choose one of thefollowing:

  • Dedicate a distinct IP address to each hostname your web server serves contentfrom.
  • Use name-based virtual hosting.

If you have been using distinct IP addresses for each hostname, you caneasily support both HTTP and HTTPS for all clients.

However, most site operators use name-based virtual hosting to conserve IPaddresses and because it's more convenient in general. The problem with IE onWindows XP and Android earlier than 2.3 is that they do not understand ServerName Indication(SNI), which is crucial for HTTPS name-based virtual hosting.

Someday—hopefully soon—clients that don't support SNI will be replacedwith modern software. Monitor the user agent string in your request logs to knowwhen enough of your user population has migrated to modern software. (You candecide what your threshold is; perhaps less than 5%, or less then 1%.)

If you don't already have HTTPS service available on your servers, enable it now(without redirecting HTTP to HTTPS; see below). Configure your web server to usethe certificates you bought and installed. You might find Mozilla's handyconfigurationgeneratoruseful.

If you have many hostnames or subdomains, they each need to use the rightcertificate.

Now, and throughout your site's lifetime, check your HTTPS configuration withQualys' handy SSL Server Test.Your site should score an A or A+; treat anything that causes a lower grade asa bug. (Today's A is tomorrow's B, because attacks against algorithms andprotocols are always improving!)

Make intrasite URLs relative

Now that you are serving your site on both HTTP and HTTPS, things need to work assmoothly as possible, regardless of protocol. An important factor is usingrelative URLs for intrasite links.

Make sure intrasite URLs and external URLs are agnostic to protocol; that is,make sure you use relative paths or leave out the protocol like//example.com/something.js.

A problem arises when you serve a page via HTTPS that includes HTTPresources, known asmixed content.Browsers warn users that the full strength of HTTPS has been lost. In fact,in the case of active mixed content (script, plug-ins, CSS, iframes), browsersoften simply won't load or execute the content at all, resulting in abroken page. And remember, it's perfectly OK to include HTTPS resources in anHTTP page.

Additionally, when you link to other pages in your site, users could getdowngraded from HTTPS to HTTP.

These problems happen when your pages include fully-qualified, intrasite URLsthat use the http:// scheme.

Don't

<h1>Welcome To Example.com</h1><script src="http://example.com/jquery.js"></script><link rel="stylesheet" href="http://assets.example.com/style.css"/><img src="http://img.example.com/logo.png"/>;<p>A <a href="http://example.com/2014/12/24/">new post on cats!</a></p>

Avoid using fully qualified intrasite URLs.

In other words, make intrasite URLs as relative as possible: eitherprotocol-relative (lacking a protocol, starting with //example.com) orhost-relative (starting with just the path, like /jquery.js).

Do

<h1>Welcome To Example.com</h1><script src="/jquery.js"></script><link rel="stylesheet" href="/assets/style.css"/><img src="/images/logo.png"/>;<p>A <a href="/2014/12/24/">new post on cats!</a></p>

Use relative intrasite URLs.

Do

<h1>Welcome To Example.com</h1><script src="//example.com/jquery.js"></script><link rel="stylesheet" href="//assets.example.com/style.css"/><img src="//img.example.com/logo.png"/>;<p>A <a href="//example.com/2014/12/24/">new post on cats!</a></p>

Or, use protocol-relative intrasite URLs.

Do

<h1>Welcome To Example.com</h1><script src="/jquery.js"></script><link rel="stylesheet" href="/assets/style.css"/><img src="/images/logo.png"/>;<p>A <a href="/2014/12/24/">new post on cats!</a></p><p>Check out this <a href="https://foo.com/"><b>other cool site.</b></a></p>

Use HTTPS URLs for intersite URLs (where possible).

Do this with a script, not by hand. If your site's content is in a database,test your script on a development copy of your database. Ifyour site's content consists of simple files, test your script on adevelopment copy of the files. Push the changes to production only after thechanges pass QA, as normal. You can use Bram van Damme'sscript or something similar todetect mixed content in your site.

When linking to other sites (as opposed to including resources from them),don't change the protocol since you don't have control over how those sitesoperate.

To make migration smoother for large sites, we recommendprotocol-relative URLs. If you are not sure whether you can fully deployHTTPS yet, forcing your site to use HTTPS for all sub-resources may backfire.There is likely to be a period of time in which HTTPS is new and weird foryou, and the HTTP site must still work as well as ever. Over time, you'llcomplete the migration and lock in HTTPS (see the next two sections).

If your site depends on scripts, images, or other resources served from a thirdparty, such as a CDN or jquery.com, you have two options:

  • Use protocol-relative URLs for these resources. If the third party does notserve HTTPS, ask them to. Most already do, including jquery.com.
  • Serve the resources from a server that you control, and which offers both HTTPand HTTPS. This is often a good idea anyway, because then you have bettercontrol over your site's appearance, performance, and security. In addition,you don't have to trust a third party, which is always nice.

Redirect HTTP to HTTPS

You need to put a canonical linkat the head of your page to tell search engines that HTTPS is the best way toget to your site.

Set <link rel="canonical" href="https://…"/> tags in your pages. Thishelps search engines determine the best way to get to your site.

Turn on Strict Transport Security and secure cookies

At this point, you are ready to "lock in" the use of HTTPS.

  • Use HTTP Strict Transport Security (HSTS) to avoid the cost of the 301 redirect.
  • Always set the Secure flag on cookies.

First, use Strict Transport Securityto tell clients that they should always connect to your server via HTTPS, evenwhen following an http:// reference. This defeats attacks such asSSL Stripping,and also avoids the round-trip cost of the 301 redirect that we enabled inRedirect HTTP to HTTPS.

Turn on HTTP Strict Transport Security (HSTS) by setting theStrict-Transport-Security header. OWASP's HSTS page has links toinstructionsfor various server software.

Most web servers offer a similar ability to add custom headers.

It is also important to make sure that clients never send cookies (such as forauthentication or site preferences) over HTTP. For example, if a user'sauthentication cookie were to be exposed in plain text, the security guarantee oftheir entire session would be destroyed—even if you have done everything elseright!

Therefore, change your web application to always set the Secure flag on cookiesthat it sets. This OWASP page explains how to set the Secureflag in several applicationframeworks. Every application framework has a way to set the flag.

Most web servers offer a simple redirect feature. Use 301 (Moved Permanently)to indicate to search engines and browsers that the HTTPS version is canonical,and redirect your users to the HTTPS version of your site from HTTP.

Search ranking

Google uses HTTPS as a positive search qualityindicator.Google also publishes a guide for how to transfer, move, or migrate yoursite while maintainingits search rank. Bing also publishes guidelines forwebmasters.

Performance

When the content and application layers are well-tuned (seeSteve Souders' books for greatadvice), the remaining TLS performance concerns are generally small, relativeto the overall cost of the application. Additionally, you can reduce andamortize those costs. (For great advice on TLS optimization and generally, seeHigh Performance Browser Networking by Ilya Grigorik.)See also Ivan Ristic's OpenSSLCookbook andBulletproof SSL And TLS.

In some cases, TLS can improve performance, mostly as a result of makingHTTP/2 possible. Chris Palmer gave a talk on HTTPS and HTTP/2 performance atChrome Dev Summit 2014.

Referer headers

When users follow links from your HTTPS site to other HTTP sites, user agentsdon't send the Referer header. If this is a problem, there are several ways tosolve it:

  • The other sites should migrate to HTTPS. If referee sites can complete theEnable HTTPS on your servers section ofthis guide, you can change links in your site to theirs from http:// tohttps://, or you can use protocol-relative links.
  • To work around a variety of problems with Referer headers, use the newReferrer Policy standard.

Because search engines are migrating to HTTPS, in the future, you are likelyto see more Referer headers when you migrate to HTTPS.

Ad revenue

Site operators that monetize their site by showing ads want to make sure thatmigrating to HTTPS does not reduce ad impressions. But due to mixed contentsecurity concerns, an HTTP <iframe> doesn't work in an HTTPS page. There is atricky collective action problem here: until advertisers publish over HTTPS,site operators cannot migrate to HTTPS without losing ad revenue; but until siteoperators migrate to HTTPS, advertisers have little motivation to publish HTTPS.

Advertisers should at least offer ad service via HTTPS (such as by completingthe "Enable HTTPS on your servers" section on this page). Many already do. Youshould ask advertisers that do not serve HTTPS at all to at least start.You may wish to defer completingMake IntraSite URLs relative until enoughadvertisers interoperate properly.

I'm a cybersecurity expert with extensive knowledge in digital security, encryption, and certificate management. My expertise includes practical experience in generating RSA key pairs, creating certificate signing requests (CSRs), and implementing HTTPS on web servers. I've worked with various certificate authorities (CAs) and understand the intricacies of securing web applications.

Now, let's delve into the concepts covered in the provided article:

  1. Generating RSA Key Pair:

    • The article recommends creating a 2048-bit RSA key pair using the openssl command:
      openssl genrsa -out www.example.com.key 2048
  2. Generating Certificate Signing Request (CSR):

    • The next step involves generating a CSR that embeds the public key and organization information:
      openssl req -new -sha256 -key www.example.com.key -out www.example.com.csr
  3. Submitting CSR to a Certificate Authority (CA):

    • Different CAs have various methods for receiving CSRs. The article suggests following the CA's instructions to submit the CSR and obtain the final certificate or certificate chain.
  4. Certificate Authority Charges:

    • The article mentions that CAs charge different amounts for vouching for the public key. It also provides an example of CA pricing for standard and wildcard certificates.
  5. Installing Certificates:

    • After obtaining the certificate, it should be installed in a non-web-accessible location on the server, such as /etc/ssl for Linux or Unix, or as per the requirements of IIS on Windows.
  6. Enabling HTTPS on Servers:

    • The article emphasizes the importance of enabling HTTPS on servers for web page security. It suggests using Mozilla's Server Configuration tool and recommends regular testing with Qualys' SSL Server Test.
  7. Handling Intrasite URLs:

    • To ensure smooth operation with both HTTP and HTTPS, the article advises using relative URLs for intrasite links. It also highlights the issues of mixed content and provides examples of how to structure URLs appropriately.
  8. Redirecting HTTP to HTTPS:

    • The article recommends redirecting HTTP to HTTPS using a canonical link in the page header and enabling HTTP Strict Transport Security (HSTS).
  9. Securing Cookies:

    • The article suggests setting the Secure flag on cookies to ensure they are transmitted securely over HTTPS.
  10. Search Engine Optimization (SEO) Considerations:

    • It discusses the positive impact of HTTPS on search rankings and provides information on setting up canonical links for search engines.
  11. Performance Considerations:

    • The article briefly touches on TLS performance concerns, mentioning that, in some cases, TLS can improve performance, especially with HTTP/2.
  12. Referer Headers and Ad Revenue:

    • It addresses issues related to Referer headers when navigating from HTTPS to HTTP sites and discusses challenges with ad revenue due to mixed content security concerns.

By following these steps and best practices, website operators can enhance the security of their web applications and ensure a smooth transition to HTTPS.

Enabling HTTPS on your servers  |  Articles  |  web.dev (2024)

FAQs

Enabling HTTPS on your servers  |  Articles  |  web.dev? ›

To use HTTPS with your domain name, you need a SSL or TLS certificate installed on your website. Your web host (Web Hosting Provider) may offer HTTPS security or you can request a SSL/TLS certificate from Certificate Authorities and install it yourself.

How do I enable HTTPS on my local server? ›

Unlock the power of HTTPS for your React localhost with these essential setup steps.
  1. Step 1: Create React app using this command.
  2. Step 2: Move to the project directory.
  3. Step 3: Install the mkcert package as global.
  4. Step 3: Generate an SSL Certificate.
Mar 15, 2024

How do I enable HTTPS on my live server? ›

vscode-liveserver-https
  1. Go to your visual code project.
  2. Create . vscode folder inside the project. ...
  3. Inside that folder create settings. json file.
  4. Paste the following code: { "liveServer.settings.https": { "enable": true, //set it true to enable the feature. " ...
  5. Start the Live Server and access your project using HTTPS.

How do I make my server HTTPS? ›

To use HTTPS with your domain name, you need a SSL or TLS certificate installed on your website. Your web host (Web Hosting Provider) may offer HTTPS security or you can request a SSL/TLS certificate from Certificate Authorities and install it yourself.

Should I enable HTTPS server? ›

HTTPS uses the SSL/TLS protocol to encrypt communications so that attackers can't steal data. SSL/TLS also confirms that a website server is who it says it is, preventing impersonations. This stops multiple kinds of cyber attacks (just like food safety prevents illness).

How do I allow HTTPS connections? ›

How to properly enable HTTPS on your server
  1. Buy an SSL certificate.
  2. Request the SSL certificate.
  3. Install the certificate.
  4. Update your site to enable HTTPS.

How do I change my server to HTTPS? ›

How to Change My Site from HTTP to HTTPS?
  1. Buy an SSL Certificate. Your website type determines what SSL certificate you need. ...
  2. Install the SSL Certificate. ...
  3. Make sure links redirect to HTTPS. ...
  4. Set up 301 redirects. ...
  5. SEO (Sitemaps, canonicals, indexing, etc.) ...
  6. Troubleshooting Possible Problems.
Mar 12, 2024

How do you check HTTPS is enabled or not? ›

The easiest way to know if a site is SSL encrypted or not is to check its URL. The URL of the site should start with HTTPS. For more details about the site's security credentials, you can click on the padlock icon near the address bar and get more information on the site's SSL certificate details.

How do I enable HTTPS only? ›

For Chrome browsers, go to Settings > Security and Privacy > Security, scroll to the bottom, and then toggle to “Always use secure connections.” For Firefox desktop, go to Settings > Privacy & Security, scroll to the bottom, and then select Enable HTTPS-Only Mode.

How do I enable HTTPS in my firewall? ›

Port 443 is the destination port that the browser uses to connect to the web server over HTTPS. By opening port 443, you allow the firewall to pass through the HTTPS traffic to your web server. Depending on your firewall type and configuration, you may need to create a rule, a policy, or an exception to open port 443.

How do I make my local IP HTTPS? ›

To use HTTPS with your local development site and access https://localhost or https://mysite.example (custom hostname), you need a TLS certificate signed by an entity your device and browser trust, called a trusted certificate authority (CA).

How do I enable HTTPS web services? ›

Enable HTTPS on your servers
  1. Generate keys and certificate signing requests. Generate a public/private key pair. Generate a certificate signing request. ...
  2. Enable HTTPS on your servers.
  3. Make intrasite URLs relative.
  4. Redirect HTTP to HTTPS.
  5. Turn on Strict Transport Security and secure cookies. Search ranking. Performance.

How do I force a website to use HTTPS? ›

In this guide, we show you how to automatically redirect HTTP to HTTPS, ensuring that your website visitors always use HTTPS.
  1. Step 1 - Go to File Manager in the Control Panel.
  2. Step 2 - Create an .htaccess file.
  3. Step 3 - Edit the .htaccess file.
  4. Step 4 - Paste in the configuration.
  5. Step 5 - Done!

What does it mean to enable HTTPS? ›

Hypertext Transfer Protocol Secure (HTTPS) is a protocol that secures communication and data transfer between a user's web browser and a website. HTTPS is the secure version of HTTP. The protocol protects users against eavesdroppers and man-in-the-middle (MitM) attacks.

How to make HTTP to HTTPS? ›

What are the steps to migrate to HTTPS?
  1. Step 1: Buying an SSL Certificate. ...
  2. Step 2: Checking compatibility with your website's features. ...
  3. Step 3: Preparing the migration. ...
  4. Step 4: Enabling HTTPS. ...
  5. Step 5: Updating features to HTTPS. ...
  6. Step 6: Adding the new version of the site to Google Search Console.
Nov 9, 2020

How to enable HTTPS on Windows server? ›

Binding a certificate to port 443 in IIS
  1. Select your site in the tree view and in the Actions pane, click Bindings. If port 443 is not available in the Bindings list, click Add. From the Type drop-down list, select https. ...
  2. From the SSL certificate drop-down list, select your certificate name and click OK.

Why is localhost not HTTPS? ›

It basically means that Local has no way of controlling the SSL certificate for your machine. Because of this, when using localhost Router Mode, you won't be able to use HTTPS. This is usually fine, and you'll still be able to deploy a site and enable HTTPS for the live site.

How do I enable HTTPS on Windows server? ›

Binding a certificate to port 443 in IIS
  1. Select your site in the tree view and in the Actions pane, click Bindings. If port 443 is not available in the Bindings list, click Add. From the Type drop-down list, select https. ...
  2. From the SSL certificate drop-down list, select your certificate name and click OK.

Top Articles
5 Alternatives to Express.js
7 Most Profitable Blog Niches for 2024 (Based On Real Data)
Craigslist Warren Michigan Free Stuff
Dannys U Pull - Self-Service Automotive Recycling
Mcgeorge Academic Calendar
Avonlea Havanese
Lamb Funeral Home Obituaries Columbus Ga
360 Training Alcohol Final Exam Answers
10000 Divided By 5
Stolen Touches Neva Altaj Read Online Free
Texas (TX) Powerball - Winning Numbers & Results
Samsung Galaxy S24 Ultra Negru dual-sim, 256 GB, 12 GB RAM - Telefon mobil la pret avantajos - Abonament - In rate | Digi Romania S.A.
Craigslist Red Wing Mn
Jang Urdu Today
Hdmovie 2
Qhc Learning
Touchless Car Wash Schaumburg
Where to eat: the 50 best restaurants in Freiburg im Breisgau
Amazing Lash Studio Casa Linda
Mj Nails Derby Ct
Naval Academy Baseball Roster
Wiseloan Login
Parkeren Emmen | Reserveren vanaf €9,25 per dag | Q-Park
European Wax Center Toms River Reviews
Manuela Qm Only
Arrest Gif
10 Best Places to Go and Things to Know for a Trip to the Hickory M...
Busted! 29 New Arrests in Portsmouth, Ohio – 03/27/22 Scioto County Mugshots
Gus Floribama Shore Drugs
Best New England Boarding Schools
Sports Clips Flowood Ms
Los Amigos Taquería Kalona Menu
JD Power's top airlines in 2024, ranked - The Points Guy
Adecco Check Stubs
Breckie Hill Fapello
Heavenly Delusion Gif
Laurin Funeral Home | Buried In Work
Sephora Planet Hollywood
Henry County Illuminate
Leena Snoubar Net Worth
Second Chance Apartments, 2nd Chance Apartments Locators for Bad Credit
Vintage Stock Edmond Ok
Poe Self Chill
Academic Notice and Subject to Dismissal
St Vrain Schoology
Suppress Spell Damage Poe
18 Seriously Good Camping Meals (healthy, easy, minimal prep! )
Edt National Board
Immobiliare di Felice| Appartamento | Appartamento in vendita Porto San
Cataz.net Android Movies Apk
Booked On The Bayou Houma 2023
Latest Posts
Article information

Author: Corie Satterfield

Last Updated:

Views: 6229

Rating: 4.1 / 5 (42 voted)

Reviews: 81% of readers found this page helpful

Author information

Name: Corie Satterfield

Birthday: 1992-08-19

Address: 850 Benjamin Bridge, Dickinsonchester, CO 68572-0542

Phone: +26813599986666

Job: Sales Manager

Hobby: Table tennis, Soapmaking, Flower arranging, amateur radio, Rock climbing, scrapbook, Horseback riding

Introduction: My name is Corie Satterfield, I am a fancy, perfect, spotless, quaint, fantastic, funny, lucky person who loves writing and wants to share my knowledge and understanding with you.