Detailed explanation of Nginx installation, SSL configuration and common commands under Centos7.x

Detailed explanation of Nginx installation, SSL configuration and common commands under Centos7.x

1. Installation

Install using yum

##Automatically install yum nginx
##Start nginx

2. SSL and default port configuration

Pan-analysis configuration

server
{
  listen 443;
  server_name *.banacoo.cn;
  ssl on;
  ssl_certificate /etc/nginx/conf.d/1_banacoo.cn_bundle.crt;
  ssl_certificate_key /etc/nginx/conf.d/2_banacoo.cn.key;
  gzip on;
  gzip_buffers 16 8k;
  gzip_comp_level 6;
  gzip_min_length 200;
  gzip_types text/css text/xml application/javascript text/javascript application/x-javascript text/plan image/jpeg image/png image/gif;
  location /room/static
    alias /home/room/;
  }
  location /statics {
    alias /home/quanyou/;
  }
  location / {
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto https;

    if ($request_method = 'OPTIONS') {
       add_header 'Access-Control-Allow-Credentials' true;
       add_header 'Access-Control-Allow-Origin' "$http_origin";
       add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
       add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
       add_header 'Access-Control-Max-Age' 1728000;
       return 204;
    }
    if ($host ~ ^(uatapi)\.banacoo\.cn$){
       proxy_pass http://127.0.0.1:8033;
    }
    if ($host ~ ^(uatapp)\.banacoo\.cn$){
       proxy_pass http://127.0.0.1:8022;
    }
    if ($host ~ ^(uatai)\.banacoo\.cn$){
       proxy_pass http://127.0.0.1:8011;
    }
    if ($host ~ ^(uatui)\.banacoo\.cn$){
       proxy_pass http://127.0.0.1:9080;
    }
    if ($host ~ ^(uatmarket)\.banacoo\.cn$){
       proxy_pass http://127.0.0.1:8088;
    }
    if ($host ~ ^(uatmarketui)\.banacoo\.cn$){
       proxy_pass http://127.0.0.1:9089;
    }
    if ($host ~ ^(uateasyjoy)\.banacoo\.cn$){
       proxy_pass http://127.0.0.1:8036;
    }
  }
  access_log logs/banacoo.cn.access.log;
}
server
{
  listen 80;
  server_name uatmarketui.banacoo.cn;
  charset utf-8;
  gzip on;
  gzip_buffers 16 8k;
  gzip_comp_level 6;
  gzip_min_length 200;
  gzip_types text/css text/xml application/javascript text/javascript application/x-javascript text/plan image/jpeg image/png image/gif;
  location / {
   proxy_pass http://127.0.0.1:9089;
  }
  autoindex on;
  autoindex_exact_size off;
  autoindex_localtime on;
  access_log logs/uatmarketui.banacoo.cn.access.log;
}
server
{
  listen 80;
  server_name uatmarket.banacoo.cn;
  charset utf-8;
  gzip on;
  gzip_buffers 16 8k;
  gzip_comp_level 6;
  gzip_min_length 200;
  gzip_types text/css text/xml application/javascript text/javascript application/x-javascript text/plan image/jpeg image/png image/gif;
  location / {
   proxy_pass http://127.0.0.1:8088;
  }
  autoindex on;
  autoindex_exact_size off;
  autoindex_localtime on;
  access_log logs/uatmarket.banacoo.cn.access.log;
}

3. Common commands

##Reload configuration nginx -s reload
##Stop service nginx -s stop

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
  • Start nginxssl configuration based on docker
  • Solution to Nginx SSL certificate configuration error
  • Nginx domain name SSL certificate configuration (website http upgraded to https)
  • Implementation of Nginx load balancing/SSL configuration
  • How to configure SSL certificate in nginx to implement https service
  • Simple steps to configure Nginx reverse proxy with SSL
  • Sample code for implementing two-way authentication with Nginx+SSL
  • Steps to configure nginx ssl to implement https access (suitable for novices)
  • Create an SSL certificate that can be used in nginx and IIS

<<:  How to generate Hive table creation statement comment script in MySQL metadata

>>:  Specific use of useRef in React

Recommend

Let's talk about the Vue life cycle in detail

Table of contents Preface 1. Life cycle in Vue2 I...

Vue3.0 handwriting magnifying glass effect

The effect to be achieved is: fixed zoom in twice...

Detailed explanation of MySQL solution to USE DB congestion

When we encounter a fault, we often think about h...

How to use Antd's Form component in React to implement form functions

1. Construction components 1. A form must contain...

Record of the actual process of packaging and deployment of Vue project

Table of contents Preface 1. Preparation - Server...

...

A brief discussion on CSS height collapse problem

Performance For example: HTML: <div class=&quo...

HTML table tag tutorial (45): table body tag

The <tbody> tag is used to define the style...

Detailed tutorial on deploying apollo with docker

1. Introduction I won’t go into details about apo...

Common attacks on web front-ends and ways to prevent them

The security issues encountered in website front-...

How to import Tomcat source code into idea

Table of contents 1. Download the tomcat code 2. ...

js to realize the function of uploading pictures

The principle of uploading pictures on the front ...

How to install multiple mysql5.7.19 (tar.gz) files under Linux

For the beginner's first installation of MySQ...