1. Introduction
Once the blog page is complete, you need to deploy it online. Originally the whole development process is based on Tencent cloud development, you can directly upload to Tencent cloud development static page hosting, and then customize the domain name, upload SSL certificate, very simple.
But for some reason, I had to run the blog page on a cloud server, configure the Nginx environment, and configure SSL certificates for HTTPS access.
Here is a record of my configuration process for sharing and future reference.
2. Domain name resolution
I am in Ali cloud to buy the domain name, to Ali cloud domain name resolution, domain name resolution.
- In the host record,
@
On behalf oflzxjack.top
. - Record type
A
It’s referring to a domain nameIPV4
Address. - The recorded value is the public IP address of the server.
3. Put the blog page on the server
Upload the packed static files to a location on the cloud server, such as the /home/www/blog directory I put on the cloud server.
Note, do not put in admin folder, may not access!! I put it in the admin folder before, but couldn’t access it. Later, I changed the path, so I could access it.
4. Enable the server port
Here I’m using ports 80 and 443 on the server, so I need to leave the ports open in the cloud server.
5. Install the SSL certificate in nginx
1. Place the SSL certificate on the server
In ali Cloud SSL certificate management, download the free certificate that has been applied for, pay attention to download the nginx type.
After downloading, there are two files, one ending with key and one ending with PEM. Put these two files in /etc/nginx-cert on the cloud server:
2. Configure nginx
In the /etc/nginx/ directory of the cloud server, create a vhost folder and store the configurations written by yourself in this folder. Then import the entire folder in the configuration file nginx.conf. In this way, if a new requirement exists, you only need to add the configuration file of the new requirement to the folder and do not modify the configuration file nginx.conf again, which improves efficiency.
After creating the vhost folder, create the configuration file blog.conf in /etc/nginx/vhost. Make sure that the suffix is conf.
The content of the document is as follows:
server{
listen 443ssl; Root /home/ WWW /blog; # replace lzxjack.top with your own domain name server_name lzxjack.top; # -404Then redirect to index.html error_page404/index.html; #- Need to replace lzxJack.top. pem with the name of the uploaded certificate file. ssl_certificate /etc/nginx/cert/lzxjack.top.pem; #- You need to replace the name of the uploaded certificate key file with lzxJack.top. key. ssl_certificate_key /etc/nginx/cert/lzxjack.top.key; ssl_session_timeout5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:! aNULL:! MD5:! ADH:! RC4; ssl_protocols TLSv1 TLSv11. TLSv12.; ssl_prefer_server_ciphers on; Location /{}} #- Set HTTP requests to automatically redirect to HTTPS server {listen80; # replace lzxjack.top with your own domain name server_name lzxjack.top; rewrite ^(.*)$ https://$host$1;
location /{}
}
Copy the code
Make your own changes according to the comments.
3. Import the self-written configuration file
On the cloud server, open the nginx.conf file in the /etc/nginx/ directory and add the following line of code to bring in the newly created configuration file. *.conf means that all files with the. Conf suffix in the vhost folder are imported.
Note: write it inside HTTP {}.
6. Complete
The cloud server enters nginx -s reload to restart nginx.
At this point, the blog page is configured. Blogs can be accessed by domain name with HTTPS access enabled.
📘📘 Welcome to my blog:
lzxjack.top/