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

Detailed installation and use of virtuoso database under Linux system

I've been researching some things about linke...

Detailed steps to install MySQL 5.6 X64 version under Linux

environment: 1. CentOS6.5 X64 2.mysql-5.6.34-linu...

Using HTML to implement a voting website cheating scheme that restricts IP

This is a cheating scheme for voting websites wit...

Brief introduction and usage of Table and div

Web front end 1 Student ID Name gender age 01 Zha...

Special commands in MySql database query

First: Installation of MySQL Download the MySQL s...

How to block and prohibit web crawlers in Nginx server

Every website usually encounters many non-search ...

Summary of two methods to implement vue printing function

Method 1: Install the plugin via npm 1. Install n...

MySQL index failure principle

Table of contents 1. Reasons for index failure 2....

Sample code for configuring nginx to support https

1. Introduction Are you still leaving your websit...

A brief discussion on mysql backup and restore for a single table

A. Installation of MySQL backup tool xtrabackup 1...

How to make a website look taller and more designed

“How to make a website look high-end? Or more des...

MySQL binlog opening steps

Binlog is a binary log file that is used to recor...

8 Reasons Why You Should Use Xfce Desktop Environment for Linux

For several reasons (including curiosity), I star...