I am writing a small program recently. Because the official website of the small program must use https, the website used to use http and used Alibaba Cloud service, so I purchased ssl service on Alibaba Cloud. The following is the configuration process. 1. First, go to Alibaba Cloud to purchase SSL. Of course, there is a free version, but it only supports one domain name, and you can only purchase 20 certificates for the same domain name. Each detailed subdomain is counted as one domain name. 2. After purchasing the SSL certificate, go to the certificate console. At this time, you need to complete the information and wait for review. It usually only takes a few minutes to pass. 3. After the review, you need to download the certificate 4. Then you need to configure the key and pem on the server. Of course, we choose to automatically generate the key here. If necessary, you can make the key yourself and follow the steps on Alibaba Cloud. As shown below: server { listen 443; server_name localhost; ssl on; root html; index index.html index.htm; ssl_certificate cert/21.pem; ssl_certificate_key cert/21.key; ssl_session_timeout 5m; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; location / { root html; index index.html index.htm; } } Don't rush to restart nginx at this time. First, check whether nginx has added the ssl module. If not, you need to recompile it. First, execute sudo apt-get install openssl libssl-dev to install ssl, and then enter the nginx directory and execute the following statement: ./configure \ --prefix=/usr/local/nginx \ --pid-path=/var/run/nginx/nginx.pid \ --lock-path=/var/lock/nginx.lock \ --error-log-path=/var/log/nginx/error.log \ --http-log-path=/var/log/nginx/access.log \ --with-http_gzip_static_module \ --http-client-body-temp-path=/var/temp/nginx/client \ --http-proxy-temp-path=/var/temp/nginx/proxy \ --http-fastcgi-temp-path=/var/temp/nginx/fastcgi \ --http-uwsgi-temp-path=/var/temp/nginx/uwsgi \ --http-scgi-temp-path=/var/temp/nginx/scgi \ --add-module=/home/scp/fastdfs-nginx-module/src \ --with-http_stub_status_module \ --with-http_ssl_module After executing the statement, execute make and then make install. At this time, if you restart nginx, the external network may still be inaccessible, because the Alibaba Cloud port needs to be configured by ourselves. You need to go to the security group to add filtering for port 443. I am using the Ubuntu system here, and you need to execute ufw allow 443 in the terminal. Then you can access the call. Then you need to jump the access of port 80 to 443 server { listen 80; server_name www.domain.com; rewrite ^(.*) https://$server_name$1 permanent; } This is the end of this article about the sample code for using nginx to convert http to https. For more information about nginx http to https conversion, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: js to achieve simple drag effect
>>: Mysql transaction concurrency problem solution
Solution to the problem that there is no unzip co...
Today, when I was configuring Tomcat to access th...
Table of contents Brief summary At noon today, th...
1. Benefits of precompilation We have all used th...
Application scenarios: One of the new requirement...
The online search to modify the grub startup time...
Volume Label, Property Name, Description 002 <...
This article example shares the specific code for...
It is provided in the form of WeChat components. ...
Loading kernel symbols using gdb arm-eabi-gdb out...
MySQL Users and Privileges In MySQL, there is a d...
The full name of Blog should be Web log, which me...
1. The significance of persistent statistical inf...
Table of contents 1. Digital Operation (1) Genera...
1. Basic Concepts //Any container can be specifie...