• Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us
TecAdmin
Menu
  • Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us

Nginx Redirect HTTP to HTTPS

Written by Rahul, Updated on March 8, 2017
Nginx http, https, nginx, virtualhost

Everyone knows that transferring private data like credentials, payment information over insecure protocol is not secure. They can easily be sniffed by an MITM attackers. This tutorial will help you redirect all incoming request on http to https url in Nginx web server.

Nginx Redirect HTTP to HTTPS

Edit http virtual host configuration file for your domain and add “return 301 https://$host$request_uri” statement under server section. This will redirect all the incoming requests on HTTP to corresponding https urls.

server {
	listen 80 default_server;
	listen [::]:80 default_server;
	server_name _;
	
	return 301 https://$host$request_uri;
}

After making changes reload or restart Nginx server.

Share it!
Share on Facebook
Share on Twitter
Share on Google+
Share on Reddit
Share on Tumblr
Rahul
Rahul
Connect on Facebook Connect on Twitter Connect on Google+

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

Related Posts

  • How to Install Multiple PHP Version with Nginx on Ubuntu 18.04 & 16.04

    June 16, 2018
  • How To Install Nginx on Ubuntu 18.04 & 16.04

    May 26, 2018
  • How To Enable TLS 1.2 Only In Nginx Web Server

    April 29, 2018
  • How To Force Redirect To HTTPS behind AWS ELB

    March 4, 2018
  • How to Secure Nginx with Let’s Encrypt on Ubuntu 18.04 & 16.04 LTS

    January 26, 2018

Leave a Reply

Cancel reply

Popular Posts

  • How to Setup Squid Proxy Server on Ubuntu 18.04 & 16.04
  • How To Install Zabbix Agent on Debian 9/8
  • How to Install and Configure Squid Proxy on Debian 9
  • How to Remove “public/index.php” from URL in Laravel
  • How To Install Wine 3 on Debian 9 (Stretch)
All rights reserved. © 2013-2018 TecAdmin.net. This site uses cookies. By using this website you agree our term and services