Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Explain in detail the correct way to redirect nginx server http to https

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

The http redirect to https uses nginx's redirect command. So how should I write the redirection? Previous versions of nginx may have used a similar format as follows.

Rewrite ^ / (. *) $http://domain.com/$1 permanent

Or

Rewrite ^ http://domain.com$request_uri? Permanent

Now that the new version of nginx has been written differently, these are no longer recommended.

The following is the latest support for redirecting nginx http pages to https pages:

Server {listen 80; server_name my.domain.com; return 301 https://$server_name$request_uri;}server {listen 443 ssl; server_name my.domain.com; [....]}

The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report