Detailed zero Nginx (2)] [Nginx-HTTP server

Here Insert Picture Description
Presentation environment:
System version : CentOS Linux Release 7.7.1908 (Core)
nginx version : nginx / 1.16.1
Of course, the official explanation is the best : English and Russian chiefs venue's official website please click here

A, HTTP server

1 Introduction

The HTTP : one is to pass data (HTML files, image files, etc.) working in the HTTP application layer protocol based on a TCP / IP communication protocol.
Hosting of: a physical server into several virtual servers, different virtual machines to access through the port, called a virtual host.
Each virtual host corresponds to a web site is to build multiple sites on a single server.

Second, the virtual host configuration

1. Prepare

mkdir /www
cd /www
mkdir tianyao //我这里的目录就以域名命名
echo 2020年4月4日 向英雄致敬,向逝者致哀。> tianyao/index.html

2. Configure virtual hosts

Virtual host in three ways

  • Port-based (based on commonly used ports)
  • Based on different IP addresses (I now use Ali cloud server, there is only one public address, temporarily unable to demonstrate)
  • Based on a different domain name
  • This /etc/nginx/conf.d/ heads are empty when there is no virtual host, you can create your configuration, but at the end .conf.
vim /etc/nginx/conf.d/tianyao.conf
# 基于域名的配置
    server {
        listen       80;
     #   server_name  www.tianyao.site;
        location / {
            root   /www/tianyao/;
            index  index.html index.htm;
        }

    }

#基于端口的网页
    server {
        listen       8080;
         location / {
            root   /www/tianyao/;
            index  index.html index.htm;
        }
    }

3. DNS settings

  • For the record domain name, add an A record to point to your host. Different analytical methods are not the same provider, demonstrated here to configure Western Digital.
    Here Insert Picture Description
  • If you do not record the domain name, you can learn to use to configure DNS on the client host:
    Windows 10: C: \ Windows \ System32 \ driversletclhosts
    Linux / Mac: / etc / hosts
  • Cloud server (home server), websites need to be able to add the record to resolve, but the filing period is longer, the record can not use free URL forwarding, but the domain name must be the real name for the record.
  • Here is Western Digital's domain name

4. Test

After setting we can enter the domain name in the browser:
Here Insert Picture Description

Here Insert Picture Description
Page prompts insecurity we are here to resolve using https

Three, Nginx related notice

Nginx环境搭建
HTTP服务器
HTTPS服务详解
反向代理
负载均衡
动静分离

(. 1) the Nginx environmental structures
(2) HTTP server (current)
(. 3) Detailed the HTTPS service
(4) reverse proxy
(5) the load balancer
(6) separating movement

Published 70 original articles · won praise 454 · views 40000 +

Guess you like

Origin blog.csdn.net/weixin_42767604/article/details/105305579