Nginx implements https website configuration code example

Nginx implements https website configuration code example

https base port 443. It is used for something called a key. Don't think you can do it without understanding these things. It's impossible.

1. Generate the key first. Let's generate it directly under Linux, assuming that the nginx directory is /usr/local/nginx-1.2.9

Next Steps

cd /usr/local/nginx-1.2.9/conf/;
mkdir ssl;
cd ssl;
# Now start creating the key. If you are not familiar with it, just follow the instructions without worrying about why you are doing this.
openssl genrsa -des3 -out server.key 1024;#This step will ask you to enter a password. Just enter it. The following step will use this password. Feel free to
openssl req -new -key server.key -out server.csr;#Enter the password you just set and press Enter
cp server.key server.key.org;
openssl rsa -in server.key.org -out server.key;#This step also requires a password
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt;
#Generation is complete. There are several files in the ssl directory: server.crt server.csr server.key server.key.org

2. In the second step, let's build a site. The configuration file is as follows. (If you don't know how to write a configuration file, you can refer to this forum)

server {
  listen 443;
  ssl on;
#Note the path and file extension ssl_certificate /usr/local/nginx-1.2.9/conf/ssl/server.crt;
  ssl_certificate_key /usr/local/nginx-1.2.9/conf/ssl/server.key;
  server_name domain name;
  root website root directory;
  location / {
    index index.html index.php;
  }
#Support PHP
  location ~ \.php{
    include fastcgi_params;
        fastcgi_split_path_info ^(.+\.php)(.*)$;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
  }
}

OK, restart nginx with nginx -s reload and see. You can access it using https

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Example of how to configure nginx to implement SSL
  • Detailed tutorial on configuring nginx for https encrypted access
  • Implementation of Nginx domain name forwarding https access
  • Alibaba Cloud Nginx configures https to implement domain name access project (graphic tutorial)
  • Detailed explanation of the principle and implementation process of Nginx configuration https
  • Nginx configures the same domain name to support both http and https access
  • Detailed configuration of Nginx supporting both Http and Https
  • Implementation of HTTP and HTTPS services with Nginx reverse proxy for multiple domain names
  • Example code for using Nginx to implement 301 redirect to https root domain name
  • How to change the website accessed by http to https in nginx

<<:  Javascript to achieve the drag effect of the login box

>>:  Html easily implements rounded rectangle

Recommend

Detailed explanation of how to install MySQL on Alibaba Cloud

As a lightweight open source database, MySQL is w...

A brief discussion on how Tomcat breaks the parent delegation mechanism

Table of contents JVM Class Loader Tomcat class l...

Solve the problem that Docker must use sudo operations

The steps are as follows 1. Create a docker group...

Detailed explanation of the usage of the ESCAPE keyword in MySQL

MySQL escape Escape means the original semantics ...

Summary of MySQL 8.0 memory-related parameters

Theoretically, the memory used by MySQL = global ...

Pure CSS code to achieve flow and dynamic line effects

Ideas: An outer box sets the background; an inner...

MySQL reports an error: Can't find file: './mysql/plugin.frm' solution

Find the problem Recently, I found a problem at w...

Vue implements top left and right sliding navigation

Navigation and other things are often used in dai...

The difference and use of json.stringify() and json.parse()

1. Differences between JSON.stringify() and JSON....

Summary of common Linux distribution mirror source configuration

I have been researching Linux recently and tried ...

Implementation of Vue counter

Table of contents 1. Implementation of counter 2....

Understanding MySQL precompilation in one article

1. Benefits of precompilation We have all used th...

Html sample code for reading and displaying pictures in a local folder

One purpose Select a local folder on the Html pag...