•  Home
  •  Dashboard
  •  Company
    • About Us
    • Blog
    • Careers
    • Contact Us
    • Data Centers
    • Looking Glass
    • Network
    • Reseller
  •  Hosting Services
    • Infrastructure
      • iColocation
    • Compute
      • cMetal
      • cVirtual
    • Storage
      • sObject
      • sBlock
    • Networking
      • nIP Transit
      • nWavelength
    • Protection
      • pBackup
      • pDDoS
  •  Solutions
    • Ecommerce
    • Finance
    • Gaming
    • Hosting
    • Management
    • Security
    • System Integrator
  •  Support
    • Community
    • Knowledge Base
    • Open A Ticket
    • Status
  •  USA & Canada: 800-933-1517
  •  International: 626-549-2801
  •  Email: sales@psychz.net
  • Services
    • new-colocation-header-img
      Infrastructure
      • iColocation
    • new-compute-header-img
      Compute
      • cMetal
      • cVirtual
    • new-storage-header-img
      Storage
      • sObject
      • sBlock
    • new-networking-header-img
      Networking
      • nIP Transit
      • nWavelength
    • new-protection-header-img
      Protection
      • pBackup
      • pDDoS
  • Solutions
    • Ecommerce
    • Security
    • Gaming
    • Hosting
    • Management
    • Finance
    • System Integrator
  • Dashboard

nginx에서 http를 https로 리디렉션합니다.

  • Home
  • Client
  • Qa Forum
  • nginx에서 http를 https로 리디렉션합니다.

Posted By: Sargis | 1 Replies | Last Reply On: Jun 06, 2017 03:20:53

nginx에서 https를 https로 리디렉션하는 방법은 무엇입니까?

Psychz - John

Votes: 0Posted On: Jun 06, 2017 03:20:53
 

Nginx is one of the world's most prominent web server solutions. It is an open source solution that provides high performance, concurrency and low memory consumption. Nginx also comes with a paid version called Nginx Plus.


Why redirect HTTP to HTTPS?

HTTP is the protocol with which the communication occurs between the web server and browser. HTTPS is another protocol used which is more secure than HTTP. The "S" stands for "secure". It uses a protocol such as SSL(Secure Sockets Layer) to encrypt data between web server and browser. Hence, it is very useful to redirect all HTTP data to HTTPS port. 


How to redirect HTTP to HTTPS?

Prerequisites

1. Setup HTTPS on Nginx - Firstly, you need to set up HTTPS on Nginx. For this, you will have to generate and private key and CSR(Certificate Signing Request) key.
2. After you have generated the key, the next step is to acquire the SSL certificate from a Certificate Authority. 
3. The third step is to configure Nginx server block by adding the SSL certificate and key. Reload the configuration to save the changes.


Redirecting all HTTP traffic to HTTPS

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

 

This a very general configuration that will redirect all the hostnames on the server. 

Let us go through the code line by line.

1. server - The name of the block in which the code is written.
2. listen 80 default_server; - The port number 80 is the "http" port and the default_server is the hostname of your server. This is to redirect all IPv4 HTTP packets incident on your server.
3. listen [::]:80 default_server; - This line functions same as above but for all IPv6 HTTP traffic.
4. return 301 https://$host$request_uri; - the code "301" is used to redirect the traffic. "https://$host$request_uri;" is the target at which all the traffic will be redirected to.

 

Here is an example for your reference.

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name test.com www.test.com;
    return 301 https://$server_name$request_uri;
}

Here, all the HTTP traffic from "test.com" and "www.test.com" are redirected to HTTPS.

 

 

 

 

 

Was this reply helpful?

Related topics

  • 창에서는 Windows Server 2003 닫는
  • 리눅스 민트의 탑 유용한 기능
  • i7 7700k Dedicated Server
  • cVirtual Rescue
  • The Future of Dedicated Servers: Trends and Predictions
  • Mirai Botnet Co-Authors Plead Guilty on Two Charges
  • Free CDN For CSS
  • Dedicated Server Rental In Chicago
  • Data Storage Server Price
  • Colocation and its basics you need to know
  • Cisco Firewall Price List In USA
  • CDN Botnet Scrapper Intro
  • Best Dedicated Server Providers In Dallas: A Comprehensive Guide
  • Access Logs Download Settings
  • Access Logs
Copyright © 2026 Psychz Networks,
A Profuse Solutions Inc Company
Hosting Services
  • Catalog
Infrastructure
  • iColocation
Compute
  • cMetal
  • cVirtual
Storage
  • sObject
  • sBlock
Networking
  • nIP Transit
  • nWavelength
Protection
  • pBackup
  • pDDoS
Company
  • About Us
  • Blog
  • Careers
  • Contact Us
  • Data Centers
  • Looking Glass
  • Network
  • Reseller
Policies
  • Acceptable Usage Policy
  • Privacy Policy
  • Service Level Agreement
  • Terms and Conditions
Support
  • Community
  • Knowledge Base
  • Open A Ticket
  • Status
Get In Touch
  • Psychz Networks,
    A Profuse Solutions Company
    611 Wilshire Blvd #300
    Los Angeles,California 90017
    USA
  • US/Canada: 800-933-1517
  • International: 626-549-2801