<span id="Label3"></p><p style="margin-top:0px;margin-bottom:10px;color:rgb(68,68,68);font-family:‘Microsoft YaHei UI‘, ‘Microsoft YaHei‘, ‘Helvetica Neue‘, Helvetica, Arial, ‘Hiragino Sans GB‘, ‘Hiragino Sans GB W3‘, ‘WenQuanYi Micro Hei‘, sans-serif;font-size:14px;white-space:normal;background-color:rgb(255,255,255);"><p style="margin-top:0px;margin-bottom:10px;color:rgb(68,68,68);font-family:‘Microsoft YaHei UI‘, ‘Microsoft YaHei‘, ‘Helvetica Neue‘, Helvetica, Arial, ‘Hiragino Sans GB‘, ‘Hiragino Sans GB W3‘, ‘WenQuanYi Micro Hei‘, sans-serif;font-size:14px;white-space:normal;background-color:rgb(255,255,255);">Reference http://blog.oldboyedu.com/nginx-https/</p></p><p style="margin-top:0px;margin-bottom:10px;color:rgb(68,68,68);font-family:‘Microsoft YaHei UI‘, ‘Microsoft YaHei‘, ‘Helvetica Neue‘, Helvetica, Arial, ‘Hiragino Sans GB‘, ‘Hiragino Sans GB W3‘, ‘WenQuanYi Micro Hei‘, sans-serif;font-size:14px;white-space:normal;background-color:rgb(255,255,255);"><p style="margin-top:0px;margin-bottom:10px;color:rgb(68,68,68);font-family:‘Microsoft YaHei UI‘, ‘Microsoft YaHei‘, ‘Helvetica Neue‘, Helvetica, Arial, ‘Hiragino Sans GB‘, ‘Hiragino Sans GB W3‘, ‘WenQuanYi Micro Hei‘, sans-serif;font-size:14px;white-space:normal;background-color:rgb(255,255,255);">Nginx HTTPS protocol requires the support of the SSL module, we use the –with-http_ssl_module parameter to add the SSL module when compiling nginx. Also need the server private key, the server certificate, if is the company external environment, this certificate needs to purchase the third Party's authoritative certificate, otherwise the user experience does not have the safeguard; here I only use and test on my vps.<br></p></p><p><p><span style="color:rgb(227,0,0);"><strong>note: If you are purchasing a Third-party service certificate</strong> <strong>,</strong> <strong>then just refer to</strong> <strong>1.3-1.4</strong> <strong>configuration information to complete the enterprise</strong> <strong>SSL</strong> <strong>Configuration Practices. </strong></span></p></p><p style="margin-top:0px;margin-bottom:10px;color:rgb(68,68,68);font-family:‘Microsoft YaHei UI‘, ‘Microsoft YaHei‘, ‘Helvetica Neue‘, Helvetica, Arial, ‘Hiragino Sans GB‘, ‘Hiragino Sans GB W3‘, ‘WenQuanYi Micro Hei‘, sans-serif;font-size:14px;white-space:normal;background-color:rgb(255,255,255);"><p style="margin-top:0px;margin-bottom:10px;color:rgb(68,68,68);font-family:‘Microsoft YaHei UI‘, ‘Microsoft YaHei‘, ‘Helvetica Neue‘, Helvetica, Arial, ‘Hiragino Sans GB‘, ‘Hiragino Sans GB W3‘, ‘WenQuanYi Micro Hei‘, sans-serif;font-size:14px;white-space:normal;background-color:rgb(255,255,255);"><strong>1.1</strong> <strong>Check</strong> <strong>Nginx</strong> <strong>of the</strong> <strong>SSL</strong> <strong>whether the module is installed</strong></p></p><pre class="brush:xml;toolbar:false"><pre class="brush:xml;toolbar:false">[[email protected] ~]# /application/nginx/sbin/nginx -vnginx version: nginx/1.6.3built by gcc 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC) tls sni support enabledconfigure arguments: –prefix=/application/ Nginx-1.6.3 –user=nginx –group=nginx –with-http_ssl_module –with-http_stub_status_module </pre></pre><p style="margin-top:0px;margin-bottom:10px;color:rgb(68,68,68);font-family:‘Microsoft YaHei UI‘, ‘Microsoft YaHei‘, ‘Helvetica Neue‘, Helvetica, Arial, ‘Hiragino Sans GB‘, ‘Hiragino Sans GB W3‘, ‘WenQuanYi Micro Hei‘, sans-serif;font-size:14px;white-space:normal;background-color:rgb(255,255,255);"><p style="margin-top:0px;margin-bottom:10px;color:rgb(68,68,68);font-family:‘Microsoft YaHei UI‘, ‘Microsoft YaHei‘, ‘Helvetica Neue‘, Helvetica, Arial, ‘Hiragino Sans GB‘, ‘Hiragino Sans GB W3‘, ‘WenQuanYi Micro Hei‘, sans-serif;font-size:14px;white-space:normal;background-color:rgb(255,255,255);"><span style="color:rgb(68,68,68);"><span style="font-family:‘Microsoft YaHei UI‘, ‘Microsoft YaHei‘, ‘Helvetica Neue‘, Helvetica, Arial, ‘Hiragino Sans GB‘, ‘Hiragino Sans GB W3‘, ‘WenQuanYi Micro Hei‘, sans-serif;"><span style="font-size:15px;"></span></span></span><br></p></p><p style="margin-top:0px;margin-bottom:10px;color:rgb(68,68,68);font-family:‘Microsoft YaHei UI‘, ‘Microsoft YaHei‘, ‘Helvetica Neue‘, Helvetica, Arial, ‘Hiragino Sans GB‘, ‘Hiragino Sans GB W3‘, ‘WenQuanYi Micro Hei‘, sans-serif;font-size:14px;"><p style="margin-top:0px;margin-bottom:10px;color:rgb(68,68,68);font-family:‘Microsoft YaHei UI‘, ‘Microsoft YaHei‘, ‘Helvetica Neue‘, Helvetica, Arial, ‘Hiragino Sans GB‘, ‘Hiragino Sans GB W3‘, ‘WenQuanYi Micro Hei‘, sans-serif;font-size:14px;"><strong>1.2</strong> <strong>preparing the private key and certificate</strong></p></p><p style="margin-top:0px;margin-bottom:10px;color:rgb(68,68,68);font-family:‘Microsoft YaHei UI‘, ‘Microsoft YaHei‘, ‘Helvetica Neue‘, Helvetica, Arial, ‘Hiragino Sans GB‘, ‘Hiragino Sans GB W3‘, ‘WenQuanYi Micro Hei‘, sans-serif;font-size:14px;"><p style="margin-top:0px;margin-bottom:10px;color:rgb(68,68,68);font-family:‘Microsoft YaHei UI‘, ‘Microsoft YaHei‘, ‘Helvetica Neue‘, Helvetica, Arial, ‘Hiragino Sans GB‘, ‘Hiragino Sans GB W3‘, ‘WenQuanYi Micro Hei‘, sans-serif;font-size:14px;"><strong>1.2.1</strong> <strong>Create a server private key</strong></p></p><pre class="brush:xml;toolbar:false"><pre class="brush:xml;toolbar:false">[[email protected] ~]# cd/application/nginx/conf/[[email protected] conf]# mkdir key[[email protected] conf]# cd Key/[[em Ail protected] key]# OpenSSL genrsa-des3-out server.key 1024Generating RSA private key, 1024x768 bit long modulus. ++++++...++++++e is 65537 (0x10001) Enter pass phrase for server.key: # #输入一个密码Verifying –enter pass phrase for server. Key: # #再次输入</pre></pre><p style="margin-top:0px;margin-bottom:10px;color:rgb(68,68,68);font-family:‘Microsoft YaHei UI‘, ‘Microsoft YaHei‘, ‘Helvetica Neue‘, Helvetica, Arial, ‘Hiragino Sans GB‘, ‘Hiragino Sans GB W3‘, ‘WenQuanYi Micro Hei‘, sans-serif;font-size:14px;"><p style="margin-top:0px;margin-bottom:10px;color:rgb (68,68,68); font-family: ' Microsoft Yahei UI ', ' Microsoft YaHei ' , ' Helvetica Neue ', Helvetica, Arial, ' Hiragino Sans GB ', ' Hiragino Sans GB W3 ', ' Wenquanyi Micro Hei ', sans-serif;font-si ze:14px; "> <strong> 1.2.2 </strong> <strong> issue Certificate </strong> </p></p><pre class="brush:xml;toolbar:false">[[email protected] key]# openssl req -new -key server.key -out server.csrenter pass phrase for server.key:you are about to be asked to enter information that will be incorporatedinto your Certificate request. what 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) [XX]:CNState or Province Name (full name) []:bjlocality Name (eg, city) [default city]:bjorganization Name (eg, company) [default company ltd]:sduorganizational unit name (eg, section) []:SACommon Name (eg, your name or your Server ' S hostname) []:XuBuSiEmail Address []:[email protected]Please enter the following ' Extra ' attributesto be sent with your certificate Requesta challenge password []: an optional company name []:</pre><p><p><strong>1.2.3</strong> <strong>Remove the server private key password</strong></p></p><pre class="brush:xml;toolbar:false"><pre class="brush:xml;toolbar:false">[[email protected] key]# cp server.key server.key.ori[[email protected] key]# OpenSSL rsa-in server.key.ori-out server.k Eyenter Pass phrase for server.key.ori:writing RSA key</pre></pre><p style="margin-top:0px;margin-bottom:10px;color:rgb(68,68,68);font-family:‘Microsoft YaHei UI‘, ‘Microsoft YaHei‘, ‘Helvetica Neue‘, Helvetica, Arial, ‘Hiragino Sans GB‘, ‘Hiragino Sans GB W3‘, ‘WenQuanYi Micro Hei‘, sans-serif;font-size:14px;"><p style="margin-top:0px;margin-bottom:10px;color:rgb(68,68,68);font-family:‘Microsoft YaHei UI‘, ‘Microsoft YaHei‘, ‘Helvetica Neue‘, Helvetica, Arial, ‘Hiragino Sans GB‘, ‘Hiragino Sans GB W3‘, ‘WenQuanYi Micro Hei‘, sans-serif;font-size:14px;"><strong>1.2.4</strong> <strong>generate a self-signed certificate using a signature request and private key</strong></p></p><pre class="brush:xml;toolbar:false"><pre class="brush:xml;toolbar:false">[[email protected] key]# openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crtsignature Oksubject=/c=cn/st=bj/l=bj/o=sdu/ou=sa/cn=xubusi/[email protected]getting private key </pre></pre><p><p> <strong style="color:rgb (68,68,68); font-family: ' Microsoft Yahei UI ', ' Microsoft Yahei ', ' Helvetica Neue ', Helvetica , Arial, ' Hiragino Sans GB ', ' Hiragino Sans GB W3 ', ' Wenquanyi Micro Hei ', sans-serif;font-size:14px; ">1.3 </strong> <strong style="color:rgb (68,68,68) font-family: ' Microsoft Yahei UI ', ' Microsoft Yahei ', ' Helvetica Neue ' , Helvetica, Arial, ' Hiragino Sans GB ', ' Hiragino Sans GB W3 ', ' Wenquanyi Micro Hei ', sans-serif;font-size:14px; "> turn on </strong> <strong style="color:rgb (68,68,68); font-family: ' Microsoft Yahei UI ', ' Microsoft Yahei ', ' Helvetica Neue ', Helvetica, Arial, ' Hiragino Sans GB ', ' Hiragino Sans GB W3 ', ' Wenquanyi Micro Hei ', sans-serif;font-size:14px; ">nginx SSL </strong> </p></p><pre class="brush:xml;toolbar:false"><pre class="brush:xml;toolbar:false">Server {server_name www.123.com;listen 80;rewrite ^ (. *) https://$server _name$1 permanent;} Server {listen 443;server_name www.123.com;ssl on;ssl_certificate key/server.crt;ssl_certificate_key key/server.key; location/{root/application/nginx-1.6.2/html/; # #nginx的默认目录index index.html index.htm index.php;}}</pre></pre><p><p>Automatic access to port 80 for port 443</p></p><p><p>Final restart of Nginx service</p></p><p><p><span style="color:rgb(68,68,68);font-family:‘Microsoft YaHei UI‘, ‘Microsoft YaHei‘, ‘Helvetica Neue‘, Helvetica, Arial, ‘Hiragino Sans GB‘, ‘Hiragino Sans GB W3‘, ‘WenQuanYi Micro Hei‘, sans-serif;font-size:14px;background-color:rgb(255,255,255);">/application/nginx/sbin/nginx-s Reload</span></p></p><p><p><span style="color:#444444;font-family:‘Microsoft YaHei UI‘, ‘Microsoft YaHei‘, ‘Helvetica Neue‘, Helvetica, Arial, ‘Hiragino Sans GB‘, ‘Hiragino Sans GB W3‘, ‘WenQuanYi Micro Hei‘, sans-serif;">View ports</span></p></p><p><p>NETSTAT-LNP | grep nginx</p></p><p><p>TCP 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 8342/nginx</p></p><p><p>TCP 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 8342/nginx</p></p><p><p>finally, you can test http://www.123.com in the browser to see if it automatically jumps to HTTPS</p></p><p><p><br></p></p><p><p>This article is from the "drifting away" blog, make sure to keep this source http://825536458.blog.51cto.com/4417836/1782847</p></p><p><p> Nginx How to turn on HTTPS protocol </p> </p></span>
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