search
HomeOperation and MaintenanceNginxNginx build https server instance analysis

Nginx build https server instance analysis

May 12, 2023 pm 05:07 PM
nginxhttps

Introduction to https

https (hypertext transfer protocol over secure socket layer) is an http channel targeting security. Simply put, it is a secure version of http. That is, an SSL layer is added under http. The security foundation of https is SSL, so the details of encryption require SSL.

It is a uri scheme (abstract identifier system), the syntax is similar to the http: system, and is used for secure http data transmission. The default port used by https is 443.

ssl certificate

Introduction to certificate types

To set up a secure server, use public Create a public-private key pair. In most cases, send the certificate request (including your own public key), your company credentials, and the fee to a Certificate Authority (ca).ca verifies the certificate request and your identity, then returns the certificate to your secure server .

But the intranet implements encryption of server-side and client-side transmission content. You can issue your own certificate and just ignore the browser distrust alert!

A certificate signed by a ca provides two important functions for your server:

  • The browser will automatically recognize the certificate and allow creation without prompting the user A secure connection

  • When a CA generates a signed certificate, it provides assurance of the identity of the organization that provides the web page to the browser.

  • Most web servers that support SSL have a list of CAs whose certificates will be automatically accepted. When a browser encounters a certificate whose authority ca is not in the list, the browser will ask the user whether to accept or reject the connection

Generate SSL Certificate

openssl genrsa -des3 -out wangzhengyi.key 2048

Nginx build https server instance analysis

##openssl req -new -key wangzhengyi.key -out wangzhengyi.csr

Nginx build https server instance analysis

Create a self-signed ca certificate

openssl req -new -x509 -days 3650 -key wangzhengyi_nopass.key -out wangzhengyi.crt

Nginx build https server instance analysis

Build https virtual host

Virtual host configuration file

upstream sslfpm {
 server 127.0.0.1:9000 weight=10 max_fails=3 fail_timeout=20s;
}

server { 
 listen   192.168.1.*:443; 
 server_name 192.168.1.*; 
 
 #为一个server开启ssl支持
 ssl         on;
 #为虚拟主机指定pem格式的证书文件
 ssl_certificate   /home/wangzhengyi/ssl/wangzhengyi.crt; 
 #为虚拟主机指定私钥文件
 ssl_certificate_key /home/wangzhengyi/ssl/wangzhengyi_nopass.key; 
 #客户端能够重复使用存储在缓存中的会话参数时间
 ssl_session_timeout 5m;
 #指定使用的ssl协议 
 ssl_protocols sslv3 tlsv1; 
 #指定许可的密码描述
 ssl_ciphers all:!adh:!export56:rc4+rsa:+high:+medium:+low:+sslv2:+exp; 
 #sslv3和tlsv1协议的服务器密码需求优先级高于客户端密码
 ssl_prefer_server_ciphers on;

 location / { 
 root /home/wangzhengyi/ssl/;
 autoindex on;
     autoindex_exact_size  off;
     autoindex_localtime on;
 } 
   # redirect server error pages to the static page /50x.html
   #
   error_page 500 502 503 504 /50x.html;
   error_page 404 /404.html;

 location = /50x.html {
     root /usr/share/nginx/www;
   }
  location = /404.html {
     root /usr/share/nginx/www;
   }
  
   # proxy the php scripts to fpm
   location ~ \.php$ {
 access_log /var/log/nginx/ssl/ssl.access.log main;
 error_log /var/log/nginx/ssl/ssl.error.log;
 root /home/wangzhengyi/ssl/; 
 fastcgi_param https on;
     include /etc/nginx/fastcgi_params; 
     fastcgi_pass  sslfpm;
   }
}

The above is the detailed content of Nginx build https server instance analysis. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:亿速云. If there is any infringement, please contact admin@php.cn delete
How to start nginxHow to start nginxApr 14, 2025 pm 01:06 PM

Question: How to start Nginx? Answer: Install Nginx Startup Nginx Verification Nginx Is Nginx Started Explore other startup options Automatically start Nginx

How to check whether nginx is startedHow to check whether nginx is startedApr 14, 2025 pm 01:03 PM

How to confirm whether Nginx is started: 1. Use the command line: systemctl status nginx (Linux/Unix), netstat -ano | findstr 80 (Windows); 2. Check whether port 80 is open; 3. Check the Nginx startup message in the system log; 4. Use third-party tools, such as Nagios, Zabbix, and Icinga.

How to close nginxHow to close nginxApr 14, 2025 pm 01:00 PM

To shut down the Nginx service, follow these steps: Determine the installation type: Red Hat/CentOS (systemctl status nginx) or Debian/Ubuntu (service nginx status) Stop the service: Red Hat/CentOS (systemctl stop nginx) or Debian/Ubuntu (service nginx stop) Disable automatic startup (optional): Red Hat/CentOS (systemctl disabled nginx) or Debian/Ubuntu (syst

How to configure nginx in WindowsHow to configure nginx in WindowsApr 14, 2025 pm 12:57 PM

How to configure Nginx in Windows? Install Nginx and create a virtual host configuration. Modify the main configuration file and include the virtual host configuration. Start or reload Nginx. Test the configuration and view the website. Selectively enable SSL and configure SSL certificates. Selectively set the firewall to allow port 80 and 443 traffic.

How to solve nginx403 errorHow to solve nginx403 errorApr 14, 2025 pm 12:54 PM

The server does not have permission to access the requested resource, resulting in a nginx 403 error. Solutions include: Check file permissions. Check the .htaccess configuration. Check nginx configuration. Configure SELinux permissions. Check the firewall rules. Troubleshoot other causes such as browser problems, server failures, or other possible errors.

How to start nginx in LinuxHow to start nginx in LinuxApr 14, 2025 pm 12:51 PM

Steps to start Nginx in Linux: Check whether Nginx is installed. Use systemctl start nginx to start the Nginx service. Use systemctl enable nginx to enable automatic startup of Nginx at system startup. Use systemctl status nginx to verify that the startup is successful. Visit http://localhost in a web browser to view the default welcome page.

How to check whether nginx is started?How to check whether nginx is started?Apr 14, 2025 pm 12:48 PM

In Linux, use the following command to check whether Nginx is started: systemctl status nginx judges based on the command output: If "Active: active (running)" is displayed, Nginx is started. If "Active: inactive (dead)" is displayed, Nginx is stopped.

How to solve nginx304 errorHow to solve nginx304 errorApr 14, 2025 pm 12:45 PM

Answer to the question: 304 Not Modified error indicates that the browser has cached the latest resource version of the client request. Solution: 1. Clear the browser cache; 2. Disable the browser cache; 3. Configure Nginx to allow client cache; 4. Check file permissions; 5. Check file hash; 6. Disable CDN or reverse proxy cache; 7. Restart Nginx.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools