2019-05-05 Day 45





DAY45:Nginx web應(yīng)用深入

1)Nginx功能模塊化:

耦合度更低,易于管理。工作中做事學(xué)會(huì)低耦合。

SQA架構(gòu)。RPC服務(wù)都屬于低耦合的技術(shù)模式。

2)虛擬主機(jī)分類介紹(省略,看書)

3)實(shí)踐基于域名的虛擬主機(jī)

[root@web02 ~]# cd /application/nginx/conf/

[root@web02 /application/nginx/conf]# egrep -v "^$|#" nginx.conf.default >nginx.conf

[root@web02 /application/nginx/conf]# cat -n nginx.conf

? ? 1 worker_processes? 1;

? ? 2 events {

? ? 3 ? ? worker_connections? 1024;

? ? 4 }

? ? 5 http {

? ? 6 ? ? include? ? ? mime.types;

? ? 7 ? ? default_type? application/octet-stream;

? ? 8 ? ? sendfile? ? ? ? on;

? ? 9 ? ? keepalive_timeout? 65;

? ? 10 ? ? server {

? ? 11 ? ? ? ? listen? ? ? 80;

? ? 12 ? ? ? ? server_name? localhost;

? ? 13 ? ? ? ? location / {

? ? 14 ? ? ? ? ? ? root? html;

? ? 15 ? ? ? ? ? ? index? index.html index.htm;

? ? 16 ? ? ? ? }

? ? 17 ? ? ? ? error_page? 500 502 503 504? /50x.html;

? ? 18 ? ? ? ? location = /50x.html {

? ? 19 ? ? ? ? ? ? root? html;

? ? 20 ? ? ? ? }

? ? 21 ? ? }

? ? 22 }

[root@web02 /application/nginx/conf]# cat -n nginx.conf

? ? 1 worker_processes? 1;

? ? 2 events {

? ? 3 ? ? worker_connections? 1024;

? ? 4 }

? ? 5 http {

? ? 6 ? ? include? ? ? mime.types;

? ? 7 ? ? default_type? application/octet-stream;

? ? 8 ? ? sendfile? ? ? ? on;

? ? 9 ? ? keepalive_timeout? 65;

? ? 10 ? ? server {

? ? 11 ? ? ? ? listen? ? ? 80;

? ? 12 ? ? ? ? server_name? www.etiantian.org;

? ? 13 ? ? ? ? location / {

? ? 14 ? ? ? ? ? ? root? html/www;

? ? 15 ? ? ? ? ? ? index? index.html index.htm;

? ? 16 ? ? ? ? }

? ? 17 ? ? }

? ? 18 }

[root@web02 /application/nginx/conf]# mkdir ../html/www

[root@web02 /application/nginx/conf]# echo "www.etiantian.org" >../html/www/index.html

[root@web02 /application/nginx/conf]# cat ../html/www/index.html

www.etiantian.org

[root@web02 /application/nginx/conf]# cat /etc/hosts

127.0.0.1? ? localhost localhost.localdomain localhost4 localhost4.localdomain4

::1? ? ? ? ? localhost localhost.localdomain localhost6 localhost6.localdomain6

172.16.1.5 lb01

172.16.1.6 lb02

172.16.1.7 web01

172.16.1.8 web02

172.16.1.9 web03

172.16.1.31 nfs01

172.16.1.41 backup

172.16.1.51 db01 db01.etiantian.org

172.16.1.61 m01

[root@web02 /application/nginx/conf]# echo "10.0.0.8 www.etiantian.org" >>/etc/hosts

[root@web02 /application/nginx/conf]# tail -1 /etc/hosts

10.0.0.8 www.etiantian.org

[root@web02 /application/nginx/conf]# ping www.etiantian.org

PING www.etiantian.org (10.0.0.8) 56(84) bytes of data.

64 bytes from www.etiantian.org (10.0.0.8): icmp_seq=1 ttl=64 time=0.050 ms

[root@web02 /application/nginx/conf]# echo 'PATH="/application/nginx/sbin:$PATH"' >>/etc/profile

[root@web02 /application/nginx/conf]# . /etc/profile

[root@web02 /application/nginx/conf]# echo $PATH

/application/nginx/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

[root@web02 /application/nginx/conf]# /application/nginx/sbin/nginx ^C

[root@web02 /application/nginx/conf]# nginx -t

nginx: the configuration file /application/nginx-1.16.0//conf/nginx.conf syntax is ok

nginx: configuration file /application/nginx-1.16.0//conf/nginx.conf test is successful

[root@web02 /application/nginx/conf]# nginx -s reload

[root@web02 /application/nginx/conf]#

[root@web02 /application/nginx/conf]# curl www.etiantian.org

www.etiantian.org

WINDOWS下測(cè)試:

C:\Windows\System32\drivers\etc\hosts

10.0.0.8 www.etiantian.org

[root@web02 /application/nginx/conf]# cat -n nginx.conf

? ? 1 worker_processes? 1;

? ? 2 events {

? ? 3 ? ? worker_connections? 1024;

? ? 4 }

? ? 5 http {

? ? 6 ? ? include? ? ? mime.types;

? ? 7 ? ? default_type? application/octet-stream;

? ? 8 ? ? sendfile? ? ? ? on;

? ? 9 ? ? keepalive_timeout? 65;

? ? 10 ? ? server {

? ? 11 ? ? ? ? listen? ? ? 80;

? ? 12 ? ? ? ? server_name? www.etiantian.org;

? ? 13 ? ? ? ? location / {

? ? 14 ? ? ? ? ? ? root? html/www;

? ? 15 ? ? ? ? ? ? index? index.html index.htm;

? ? 16 ? ? ? ? }

? ? 17 ? ? }

? ? 18 ? ? server {

? ? 19 ? ? ? ? listen? ? ? 80;

? ? 20 ? ? ? ? server_name? bbs.etiantian.org;

? ? 21 ? ? ? ? location / {

? ? 22 ? ? ? ? ? ? root? html/bbs;

? ? 23 ? ? ? ? ? ? index? index.html index.htm;

? ? 24 ? ? ? ? }

? ? 25 ? ? }

? ? 26 ? ? server {

? ? 27 ? ? ? ? listen? ? ? 80;

? ? 28 ? ? ? ? server_name? blog.etiantian.org;

▽? 29 ? ? ? ? location / {

? ? 30 ? ? ? ? ? ? root? html/blog;

? ? 31 ? ? ? ? ? ? index? index.html index.htm;

? ? 32 ? ? ? ? }

? ? 33 ? ? }

? ? 34 }

[root@web02 /application/nginx/conf]# mkdir ../html/{bbs,blog}

[root@web02 /application/nginx/conf]# echo "bbs.etiantian.org" >../html/bbs/index.html

[root@web02 /application/nginx/conf]# echo "blog.etiantian.org" >../html/blog/index.html

[root@web02 /application/nginx/conf]#

[root@web02 /application/nginx/conf]#

[root@web02 /application/nginx/conf]# cat ../html/blog/index.html

blog.etiantian.org

[root@web02 /application/nginx/conf]# cat ../html/bbs/index.html

bbs.etiantian.org

[root@web02 /application/nginx/conf]#

[root@web02 /application/nginx/conf]# nginx -t

nginx: the configuration file /application/nginx-1.16.0//conf/nginx.conf syntax is ok

nginx: configuration file /application/nginx-1.16.0//conf/nginx.conf test is successful

[root@web02 /application/nginx/conf]# nginx -s reload

[root@web02 /application/nginx/conf]#

[root@web02 /application/nginx/conf]# vim /etc/hosts

127.0.0.1? ? localhost localhost.localdomain localhost4 localhost4.localdomain4

::1? ? ? ? ? localhost localhost.localdomain localhost6 localhost6.localdomain6

172.16.1.5 lb01

172.16.1.6 lb02

172.16.1.7 web01

172.16.1.8 web02

172.16.1.9 web03

172.16.1.31 nfs01

172.16.1.41 backup

172.16.1.51 db01 db01.etiantian.org

172.16.1.61 m01

10.0.0.8 www.etiantian.org bbs.etiantian.org blog.etiantian.org? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

"/etc/hosts" 12L, 396C 已寫入? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

[root@web02 /application/nginx/conf]# ping bbs.etiantian.org

PING www.etiantian.org (10.0.0.8) 56(84) bytes of data.

64 bytes from www.etiantian.org (10.0.0.8): icmp_seq=1 ttl=64 time=0.022 ms

64 bytes from www.etiantian.org (10.0.0.8): icmp_seq=2 ttl=64 time=0.056 ms

^C

--- www.etiantian.org ping statistics ---

2 packets transmitted, 2 received, 0% packet loss, time 1000ms

rtt min/avg/max/mdev = 0.022/0.039/0.056/0.017 ms

[root@web02 /application/nginx/conf]# ping blog.etiantian.org

PING www.etiantian.org (10.0.0.8) 56(84) bytes of data.

64 bytes from www.etiantian.org (10.0.0.8): icmp_seq=1 ttl=64 time=0.228 ms

64 bytes from www.etiantian.org (10.0.0.8): icmp_seq=2 ttl=64 time=0.029 ms

^C

--- www.etiantian.org ping statistics ---

2 packets transmitted, 2 received, 0% packet loss, time 1001ms

rtt min/avg/max/mdev = 0.029/0.128/0.228/0.100 ms

[root@web02 /application/nginx/conf]#

[root@web02 /application/nginx/conf]#

[root@web02 /application/nginx/conf]#

[root@web02 /application/nginx/conf]# curl www.etiantian.org

www.etiantian.org

[root@web02 /application/nginx/conf]# curl bbs.etiantian.org

bbs.etiantian.org

[root@web02 /application/nginx/conf]# curl blog.etiantian.org

blog.etiantian.org

基于端口虛擬主機(jī)實(shí)踐:

[root@web02 ~]# cd /application/nginx/conf/

[root@web02 /application/nginx/conf]# cp nginx.conf{,_BaseName}

[root@web02 /application/nginx/conf]# ls

fastcgi.conf? ? ? ? ? ? index.html? mime.types.default? scgi_params? ? ? ? ? win-utf

fastcgi.conf.default? ? koi-utf? ? nginx.conf? ? ? ? ? scgi_params.default

fastcgi_params? ? ? ? ? koi-win? ? nginx.conf_BaseName? uwsgi_params

fastcgi_params.default? mime.types? nginx.conf.default? uwsgi_params.default

[root@web02 /application/nginx/conf]# vim nginx.conf

[root@web02 /application/nginx/conf]# vim nginx.conf

? ? keepalive_timeout? 65;

? ? server {

? ? ? ? listen? ? ? 80;

? ? ? ? server_name? www.etiantian.org;

? ? ? ? location / {

? ? ? ? ? ? root? html/www;

? ? ? ? ? ? index? index.html index.htm;

? ? ? ? }

? ? }

? ? server {

? ? ? ? listen? ? ? 81;

? ? ? ? server_name? bbs.etiantian.org;

? ? ? ? location / {

? ? ? ? ? ? root? html/bbs;

? ? ? ? ? ? index? index.html index.htm;

? ? ? ? }

? ? }

? ? server {

? ? ? ? listen? ? ? 82;

? ? ? ? server_name? blog.etiantian.org;

"nginx.conf" 34L, 753C 已寫入? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

[root@web02 /application/nginx/conf]# netstat -lntup|grep nginx

tcp? ? ? ? 0? ? ? 0 0.0.0.0:80? ? ? ? ? ? ? 0.0.0.0:*? ? ? ? ? ? ? LISTEN? ? ? 14322/nginx: master

[root@web02 /application/nginx/conf]# nginx -t

nginx: the configuration file /application/nginx-1.16.0//conf/nginx.conf syntax is ok

nginx: configuration file /application/nginx-1.16.0//conf/nginx.conf test is successful

[root@web02 /application/nginx/conf]# nginx -s reload

[root@web02 /application/nginx/conf]# netstat -lntup|grep nginx

tcp? ? ? ? 0? ? ? 0 0.0.0.0:80? ? ? ? ? ? ? 0.0.0.0:*? ? ? ? ? ? ? LISTEN? ? ? 14322/nginx: master

tcp? ? ? ? 0? ? ? 0 0.0.0.0:81? ? ? ? ? ? ? 0.0.0.0:*? ? ? ? ? ? ? LISTEN? ? ? 14322/nginx: master

tcp? ? ? ? 0? ? ? 0 0.0.0.0:82? ? ? ? ? ? ? 0.0.0.0:*? ? ? ? ? ? ? LISTEN? ? ? 14322/nginx: master

[root@web02 /application/nginx/conf]# curl www.etiantian.org

www.etiantian.org

[root@web02 /application/nginx/conf]# curl bbs.etiantian.org:81

bbs.etiantian.org

[root@web02 /application/nginx/conf]# curl bbs.etiantian.org

www.etiantian.org

[root@web02 /application/nginx/conf]# curl blog.etiantian.org:82

blog.etiantian.org

[root@web02 /application/nginx/conf]# curl blog.etiantian.org

www.etiantian.org

1)瀏覽器輸入www.etiantian.org

2)找LDNS-授權(quán)DNS獲取到IP。

3)請(qǐng)求服務(wù)器發(fā)起三次握手。

4)建立http請(qǐng)求。

(10.0.0.8 80)

5)發(fā)起HTTP請(qǐng)求報(bào)文。

(4)先匹配請(qǐng)求的端口。

(5)然后匹配Server標(biāo)簽域名

(6)把對(duì)應(yīng)域名下面站點(diǎn)目錄

? ? ? 下的首頁(yè)文件發(fā)給客戶端。

(7)如果沒有匹配的域名,

? ? ? ? 就把第一個(gè)虛擬機(jī)

? ? ? 主機(jī)發(fā)給客戶端


基于IP的虛擬主機(jī):

[root@web02 ~]# ip addr add 10.0.0.9 dev eth0 label eth0:9

[root@web02 ~]# ip addr add 10.0.0.10 dev eth0 label eth0:10

[root@web02 ~]# ifconfig

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>? mtu 1500

? ? ? ? inet 10.0.0.8? netmask 255.255.255.0? broadcast 10.0.0.255

? ? ? ? inet6 fe80::20c:29ff:fe12:170c? prefixlen 64? scopeid 0x20<link>

? ? ? ? ether 00:0c:29:12:17:0c? txqueuelen 1000? (Ethernet)

? ? ? ? RX packets 21765? bytes 18029629 (17.1 MiB)

? ? ? ? RX errors 0? dropped 0? overruns 0? frame 0

? ? ? ? TX packets 12171? bytes 1426129 (1.3 MiB)

? ? ? ? TX errors 0? dropped 0 overruns 0? carrier 0? collisions 0

eth0:9: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>? mtu 1500

? ? ? ? inet 10.0.0.9? netmask 255.255.255.255? broadcast 0.0.0.0

? ? ? ? ether 00:0c:29:12:17:0c? txqueuelen 1000? (Ethernet)

eth0:10: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>? mtu 1500

? ? ? ? inet 10.0.0.10? netmask 255.255.255.255? broadcast 0.0.0.0

[root@web02 /application/nginx/conf]# cat -n nginx.conf

? ? 1 worker_processes? 1;

? ? 2 events {

? ? 3 ? ? worker_connections? 1024;

? ? 4 }

? ? 5 http {

? ? 6 ? ? include? ? ? mime.types;

? ? 7 ? ? default_type? application/octet-stream;

? ? 8 ? ? sendfile? ? ? ? on;

? ? 9 ? ? keepalive_timeout? 65;

? ? 10 ? ? server {

? ? 11 ? ? ? ? listen? ? ? 10.0.0.8:80;

? ? 12 ? ? ? ? server_name? www.etiantian.org;

? ? 13 ? ? ? ? location / {

? ? 14 ? ? ? ? ? ? root? html/www;

? ? 15 ? ? ? ? ? ? index? index.html index.htm;

? ? 16 ? ? ? ? }

? ? 17 ? ? }

? ? 18 ? ? server {

? ? 19 ? ? ? ? listen? ? ? 10.0.0.9:80;

? ? 20 ? ? ? ? server_name? bbs.etiantian.org;

? ? 21 ? ? ? ? location / {

? ? 22 ? ? ? ? ? ? root? html/bbs;

? ? 23 ? ? ? ? ? ? index? index.html index.htm;

? ? 24 ? ? ? ? }

? ? 25 ? ? }

? ? 26 ? ? server {

? ? 27 ? ? ? ? listen? ? ? 10.0.0.10:80;

? ? 28 ? ? ? ? server_name? blog.etiantian.org;

? ? 29 ? ? ? ? location / {

? ? 30 ? ? ? ? ? ? root? html/blog;

? ? 31 ? ? ? ? ? ? index? index.html index.htm;

? ? 32 ? ? ? ? }

? ? 33 ? ? }

? ? 34 }

[root@web02 /application/nginx/conf]# nginx -t

nginx: the configuration file /application/nginx-1.16.0//conf/nginx.conf syntax is ok

nginx: configuration file /application/nginx-1.16.0//conf/nginx.conf test is successful

[root@web02 /application/nginx/conf]# nginx -s reload

[root@web02 /application/nginx/conf]# netstat -lntup|grep nginx

tcp? ? ? ? 0? ? ? 0 0.0.0.0:80? ? ? ? ? ? ? 0.0.0.0:*? ? ? ? ? ? ? LISTEN? ? ? 14322/nginx: master

tcp? ? ? ? 0? ? ? 0 0.0.0.0:81? ? ? ? ? ? ? 0.0.0.0:*? ? ? ? ? ? ? LISTEN? ? ? 14322/nginx: master

tcp? ? ? ? 0? ? ? 0 0.0.0.0:82? ? ? ? ? ? ? 0.0.0.0:*? ? ? ? ? ? ? LISTEN? ? ? 14322/nginx: master

[root@web02 /application/nginx/conf]# nginx -s stop

[root@web02 /application/nginx/conf]# nginx

[root@web02 /application/nginx/conf]# netstat -lntup|grep nginx

tcp? ? ? ? 0? ? ? 0 10.0.0.10:80? ? ? ? ? ? 0.0.0.0:*? ? ? ? ? ? ? LISTEN? ? ? 14967/nginx: master

tcp? ? ? ? 0? ? ? 0 10.0.0.9:80? ? ? ? ? ? 0.0.0.0:*? ? ? ? ? ? ? LISTEN? ? ? 14967/nginx: master

tcp? ? ? ? 0? ? ? 0 10.0.0.8:80? ? ? ? ? ? 0.0.0.0:*? ? ? ? ? ? ? LISTEN? ? ? 14967/nginx: master

[root@web02 /application/nginx/conf]# curl 10.0.0.8

www.etiantian.org

[root@web02 /application/nginx/conf]# curl 10.0.0.9

bbs.etiantian.org

[root@web02 /application/nginx/conf]# curl 10.0.0.10

blog.etiantian.org

一:什么是惡意域名解析

? ? ? ? 一般情況下,要使域名能訪問到網(wǎng)站需要兩步,第一步,將域名解析到網(wǎng)站所在的主機(jī),第二步,在web服務(wù)器中將域名與相應(yīng)的網(wǎng)站綁定。但是,如果通過主機(jī)IP能直接訪問某網(wǎng)站,那么把域名解析到這個(gè)IP也將能訪問到該網(wǎng)站,而無需在主機(jī)上綁定,也就是說任何人將任何域名解析到這個(gè)IP就能訪問到這個(gè)網(wǎng)站。

二:惡意域名解析的危害

? ? ? ? 可能您并不介意通過別人的域名訪問到您的網(wǎng)站,但是如果這個(gè)域名是未備案域名呢?

? ? ? ? 假如那域名是不友善的域名,比如曾經(jīng)指向非法網(wǎng)站,容易引發(fā)搜索引擎懲罰,連帶IP受到牽連。即使域名沒什么問題,但流量也會(huì)被劫持到別的域名,從而遭到廣告聯(lián)盟的封殺。

三;如何防止,配置里第一個(gè)標(biāo)簽如下配置

server{

listen 80;

server_name _default;

return 500;

}

優(yōu)化nginx配置文件:

[root@web02 /application/nginx/conf]# mkdir extra? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

[root@web02 /application/nginx/conf]# sed -n '10,17p' nginx.conf

? ? server {

? ? ? ? listen? ? ? 80;

? ? ? ? server_name? www.etiantian.org;

? ? ? ? location / {

? ? ? ? ? ? root? html/www;

? ? ? ? ? ? index? index.html index.htm;

? ? ? ? }

? ? }

[root@web02 /application/nginx/conf]# sed -n '10,17p' nginx.conf >extra/01_www.conf

[root@web02 /application/nginx/conf]# sed -n '18,25p' nginx.conf

? ? server {

? ? ? ? listen? ? ? 80;

? ? ? ? server_name? bbs.etiantian.org;

? ? ? ? location / {

? ? ? ? ? ? root? html/bbs;

? ? ? ? ? ? index? index.html index.htm;

? ? ? ? }

? ? }

[root@web02 /application/nginx/conf]# sed -n '18,25p' nginx.conf >extra/02_bbs.conf

[root@web02 /application/nginx/conf]# sed -n '26,33p' nginx.conf

? ? server {

? ? ? ? listen? ? ? 80;

? ? ? ? server_name? blog.etiantian.org;

? ? ? ? location / {

? ? ? ? ? ? root? html/blog;

? ? ? ? ? ? index? index.html index.htm;

? ? ? ? }

? ? }

[root@web02 /application/nginx/conf]# sed -n '26,33p' nginx.conf >extra/03_blog.conf

[root@web02 /application/nginx/conf]#

[root@web02 /application/nginx/conf]#

[root@web02 /application/nginx/conf]# cd extra/

[root@web02 /application/nginx/conf/extra]# cat 01_www.conf

? ? server {

? ? ? ? listen? ? ? 80;

? ? ? ? server_name? www.etiantian.org;

? ? ? ? location / {

? ? ? ? ? ? root? html/www;

? ? ? ? ? ? index? index.html index.htm;

? ? ? ? }

? ? }

[root@web02 /application/nginx/conf/extra]# cat 02_bbs.conf

? ? server {

? ? ? ? listen? ? ? 80;

? ? ? ? server_name? bbs.etiantian.org;

? ? ? ? location / {

? ? ? ? ? ? root? html/bbs;

? ? ? ? ? ? index? index.html index.htm;

? ? ? ? }

? ? }

[root@web02 /application/nginx/conf/extra]# cat 03_blog.conf

? ? server {

? ? ? ? listen? ? ? 80;

? ? ? ? server_name? blog.etiantian.org;

? ? ? ? location / {

? ? ? ? ? ? root? html/blog;

? ? ? ? ? ? index? index.html index.htm;

? ? ? ? }

? ? }

[root@web02 /application/nginx/conf/extra]#

[root@web02 /application/nginx/conf/extra]# cd ../

[root@web02 /application/nginx/conf]# sed -n '10,33p' nginx.conf

? ? server {

? ? ? ? listen? ? ? 80;

? ? ? ? server_name? www.etiantian.org;

? ? ? ? location / {

? ? ? ? ? ? root? html/www;

? ? ? ? ? ? index? index.html index.htm;

? ? ? ? }

? ? }

? ? server {

? ? ? ? listen? ? ? 80;

? ? ? ? server_name? bbs.etiantian.org;

? ? ? ? location / {

? ? ? ? ? ? root? html/bbs;

? ? ? ? ? ? index? index.html index.htm;

? ? ? ? }

? ? }

? ? server {

? ? ? ? listen? ? ? 80;

? ? ? ? server_name? blog.etiantian.org;

? ? ? ? location / {

? ? ? ? ? ? root? html/blog;

? ? ? ? ? ? index? index.html index.htm;

? ? ? ? }

? ? }

[root@web02 /application/nginx/conf]# sed -i '10,33d' nginx.conf

[root@web02 /application/nginx/conf]# sed -i '10 i include extra/01_www.conf;\ninclude extra/02_bbs.conf;\ninclude extra/03_blog.conf;'? nginx.conf

[root@web02 /application/nginx/conf]#

[root@web02 /application/nginx/conf]#

[root@web02 /application/nginx/conf]#

[root@web02 /application/nginx/conf]#

[root@web02 /application/nginx/conf]# cat nginx.conf

worker_processes? 1;

events {

? ? worker_connections? 1024;

}

http {

? ? include? ? ? mime.types;

? ? default_type? application/octet-stream;

? ? sendfile? ? ? ? on;

? ? keepalive_timeout? 65;

include extra/01_www.conf;

include extra/02_bbs.conf;

include extra/03_blog.conf;

}

[root@web02 /application/nginx/conf]# nginx -t

nginx: the configuration file /application/nginx-1.16.0//conf/nginx.conf syntax is ok

nginx: configuration file /application/nginx-1.16.0//conf/nginx.conf test is successful

[root@web02 /application/nginx/conf]# nginx -s reload

[root@web02 /application/nginx/conf]# curl www.etiantian.org

www.etiantian.org

[root@web02 /application/nginx/conf]# curl bbs.etiantian.org

bbs.etiantian.org

[root@web02 /application/nginx/conf]# curl blog.etiantian.org

blog.etiantian.org

別名:一個(gè)名字以外的另一名字

張三、小張

www.etiantian.org

etiantian.org

[root@web02 /application/nginx/conf]# cat extra/01_www.conf

? ? server {

? ? ? ? listen? ? ? 80;

? ? ? ? server_name? www.etiantian.org etiantian.org;

? ? ? ? location / {

? ? ? ? ? ? root? html/www;

? ? ? ? ? ? index? index.html index.htm;

? ? ? ? }

? ? }

[root@web02 /application/nginx/conf]# nginx -v

nginx version: nginx/1.16.0

[root@web02 /application/nginx/conf]#

[root@web02 /application/nginx/conf]#

[root@web02 /application/nginx/conf]# nginx -V

nginx version: nginx/1.16.0

built by gcc 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC)

built with OpenSSL 1.0.2k-fips? 26 Jan 2017

TLS SNI support enabled

configure arguments: --user=www --group=www --prefix=/application/nginx-1.16.0/ --with-http_stub_status_module --with-http_ssl_module --with-pcre

[root@web02 /application/nginx/conf]# cat extra/04_status.conf

#status

server{

? ? listen? 80;

? ? server_name? status.etiantian.org;

? ? location / {

? ? ? stub_status on;

? ? ? access_log? off;

? ? }

? }


10.0.0.8 www.etiantian.org bbs.etiantian.org blog.etiantian.org status.etiantian.org

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容