Implementation of nginx proxy port 80 to port 443

Implementation of nginx proxy port 80 to port 443

The nginx.conf configuration file is as follows

user nginx;
worker_processes 1;

error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;


events {
  worker_connections 1024;
}


http {
  include /etc/nginx/mime.types;
  default_type application/octet-stream;

  log_format main '$remote_addr - $remote_user [$time_local] "$request" '
           '$status $body_bytes_sent "$http_referer" '
           '"$http_user_agent" "$http_x_forwarded_for"';

  access_log /var/log/nginx/access.log main;

  sendfile on;
  #tcp_nopush on;

  keepalive_timeout 65;

  #gzip on;

  include /etc/nginx/conf.d/*.conf;
 
 # The attributes starting with ssl in the following attributes are related to certificate configuration. Please configure other attributes according to your needs.
 server {
 listen 443 ssl; #The SSL protocol access port number is 443. If SSL is not added here, Nginx may fail to start.
 server_name localhost; #Change localhost to the domain name bound to your certificate, for example: www.example.com.
 root html;
 index index.html index.htm;
 ssl_certificate /etc/nginx/huashengshu.top.pem; #Replace with the file name of your certificate.
 ssl_certificate_key /etc/nginx/huashengshu.top.key; #Replace with the key file name of your certificate.
 ssl_session_timeout 5m;
 ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; #Use this encryption suite.
 ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #Use this protocol for configuration.
 ssl_prefer_server_ciphers on;  
 location / {
  root /etc/nginx/hss; #Site directory.
  index index.html index.htm;  
 }
 }
 

 server {
 listen 80;
 server_name huashengshu.top;
 rewrite ^(.*)$ https://${server_name}$1 permanent; 
 }

}

What works is

 server {
 listen 80;
 server_name huashengshu.top;
 rewrite ^(.*)$ https://${server_name}$1 permanent; 
 }

This is the end of this article about how to use nginx proxy port 80 to port 443. For more information about how to use nginx proxy port 80 to port 443, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • 18 Nginx proxy cache configuration tips that operators must know (which ones do you know?)
  • Summary of some common configurations and techniques of Nginx
  • Sharing tips on limiting the number of connections in nginx
  • A brief introduction to some tips for optimizing Nginx servers
  • Nginx Rewrite rules and usage introduction and skills examples
  • Nginx forwarding based on URL parameters
  • Detailed explanation of several error handling when Nginx fails to start
  • Summary of common Nginx techniques and examples

<<:  js canvas implements verification code and obtains verification code function

>>:  MySQL8 Installer version graphic tutorial

Recommend

Detailed explanation of html-webpack-plugin usage

Recently, I used html-webapck-plugin plug-in for ...

Window.name solves the problem of cross-domain data transmission

<br />Original text: http://research.microso...

Tips for viewing text in Linux (super practical!)

Preface In daily development, we often need to pe...

Implementation steps of encapsulating components based on React

Table of contents Preface How does antd encapsula...

Web Design Tutorial (4): About Materials and Expressions

<br />Previous Web Design Tutorial: Web Desi...

Implementation of MySQL scheduled backup script under Windows

On a Windows server, if you want to back up datab...

Detailed process of changing apt source to Alibaba Cloud source in Ubuntu 18.04

Table of contents Preface: Ubuntu 18.04 changes a...

How to use bind to set up DNS server

DNS (Domain Name Server) is a server that convert...

CSS position fixed left and right double positioning implementation code

CSS Position The position attribute specifies the...

MySQL 8.0.19 installation and configuration method graphic tutorial

This article records the installation and configu...

How to preview pdf file using pdfjs in vue

Table of contents Preface think Library directory...

Detailed graphic explanation of sqlmap injection

Table of contents 1. We found that this website m...

Implementation code for adding slash to Vue element header

<template> <div class="app-containe...