Nginx enforces HTTPS access (HTTP jumps to HTTPS)

Source: Internet
Author: User

The business needs to provide services over HTTPS and enter HTTP to automatically jump to HTTPS.

The rewrite method of 1.nginx

Rewrite all HTTP requests over rewrite to HTTPS

server {
Listen 80;
server_name qunyingliu.qq.com;
Rewrite ^ (. *) $ https://$host $ permanent;
}

2. index.html Refresh Web page

Jump

Index.html

Nginx Configuration

server {
Listen 80;
server_name qunyingliu.qq.com;

Location/{
#index. HTML is placed in the root directory of the virtual host listener
root/data/web/websites/qunyingliu.qq.com/http;
}
#将404的页面重定向到https的首页
Error_page 404 https://qunyingliu.qq.com/;
}


Nginx enforces HTTPS access (HTTP jumps to HTTPS)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.