亚洲精品久久久中文字幕-亚洲精品久久片久久-亚洲精品久久青草-亚洲精品久久婷婷爱久久婷婷-亚洲精品久久午夜香蕉

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

Nginx主機(jī)域名配置實(shí)現(xiàn)

瀏覽:127日期:2023-06-15 15:23:32
目錄
  • 一、配置多個(gè)端口訪問(wèn)不同文件
  • 二、配置不同域名訪問(wèn)不同文件
  • 三、配置不同域名訪問(wèn)同個(gè)文件

一、配置多個(gè)端口訪問(wèn)不同文件

相同域名,不同端口,不同文件

#兩個(gè)不同文件夾,分別存放不同文件[root@nginx ~]# mkdir /www/work_01 -p[root@nginx ~]# mkdir /www/work_02[root@nginx ~]# vim /www/work_01/index.html this is work_01![root@nginx ~]# vim /www/work_02/index.htmlthis is work_02!

#編輯其中server模塊,把端口80的站點(diǎn)指向一個(gè)文件夾,再?gòu)?fù)制這個(gè)server到下面,修改端口

[root@nginx ~]# vim /usr/local/nginx/conf/nginx.confworker_processes  1;events {    worker_connections  1024;}http {    include       mime.types;    default_type  application/octet-stream;    sendfileon;    keepalive_timeout  65;#80端口,指向work_01的文件夾    server {listen       80;server_name  localhost;location / {    root   /www/work_01;    index  index.html index.htm;}error_page   500 502 503 504  /50x.html;location = /50x.html {    root   html;}    }#8080端口,指向work_02的文件夾    server {    listen 8080;    server_name localhost;    location / {    root /www/work_02;    index index.html index.htm;    }    error_page 500 502 503 504 /50x.html;    location = /50x.html {root html;    }}}

#瀏覽器訪問(wèn)

二、配置不同域名訪問(wèn)不同文件

相同端口,不同域名,不同文件

#四個(gè)文件夾,分別對(duì)應(yīng)不同文件內(nèi)容

[root@nginx ~]# cd /www/[root@nginx www]# mkdir work_03[root@nginx www]# mkdir work_04[root@nginx www]# echo "This is work_03" > work_03/index.html[root@nginx www]# echo "This is work_04" > work_04/index.html[root@nginx www]# lswork_01  work_02  work_03  work_04

#修改配置文件

[root@nginx www]# vim /usr/local/nginx/conf/nginx.confworker_processes  1;events {    worker_connections  1024;}http {    include       mime.types;    sendfileon;    keepalive_timeout  65;#通配符在后的域名    server {listen       80;server_name  www.haha.*;location / {    root   /www/work_01;    index  index.html index.htm;}error_page   500 502 503 504  /50x.html;location = /50x.html {    root   html;}    }#精確域名    server {    listen 80;    server_name www.haha.com;    location / {    root /www/work_02;    index index.html index.htm;    }    error_page 500 502 503 504 /50x.html;    location = /50x.html {root html;    }}#通配符在前的域名    server {listen 80;server_name *.haha.com;    location / {root /www/work_03;index index.html index.htm;    }    error_page 500 502 503 504 /50x.html;    location = /50x.html {root html;    }}#正則表達(dá)式域名    server {listen 80;server_name ~\w+.com;    location / {root /www/work_04;index index.html index.htm;    }    error_page 500 502 503 504 /50x.html;    location = /50x.html {root html;    }}}[root@nginx www]# systemctl restart nginx

#配置宿主機(jī)host文件,在"C:\Windows\System32\drivers\etc\hosts"

#訪問(wèn)結(jié)果

sever_name匹配順序:

  • 精準(zhǔn)匹配
  • 通配符開(kāi)頭,比如*.example.com
  • 通配符結(jié)尾,比如www.example.*
  • 正則表達(dá)式
  • 默認(rèn)值

三、配置不同域名訪問(wèn)同個(gè)文件

相同端口,不同域名 ,同個(gè)文件

[root@nginx ~]# vim /usr/local/nginx/conf/nginx.confworker_processes  1;events {    worker_connections  1024;}http {    include       mime.types;    default_type  application/octet-stream;    sendfileon;    keepalive_timeout  65;#只需要在server_name再添加一個(gè)域名,不需要在復(fù)制一個(gè)server_name    server {listen       80;server_name  www.xixi.com www.qiqi.com;location / {    root   /www/work_01;    index  index.html index.htm;}error_page   500 502 503 504  /50x.html;location = /50x.html {    root   html;}    }}[root@nginx ~]# systemctl restart nginx

#該宿主機(jī)的host文件

#訪問(wèn)結(jié)果如下:

到此這篇關(guān)于Nginx主機(jī)域名配置實(shí)現(xiàn)的文章就介紹到這了,更多相關(guān)Nginx主機(jī)域名配置內(nèi)容請(qǐng)搜索以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持!

標(biāo)簽: Nginx
主站蜘蛛池模板: 欧洲性大片xxxxx久久久 | 国产精品亚欧美一区二区三区 | 欧美激情在线精品三区 | 永久在线| 麻豆传煤入口1.5 | 欧美黑人与白人做爰 | 亚洲欧美日韩中文字幕一区二区三区 | 婷婷综合缴情亚洲狠狠图片 | 免费视频久久 | 2021中文字幕| 国产一级特黄生活片 | 一级毛片视频在线观看 | 亚洲精品亚洲人成人网 | 精品国产品国语在线不卡丶 | 韩国一级黄色大片 | 又做又爱高清免费观看 | 综合亚洲精品一区二区三区 | 国产精品免费观看视频 | 免费一级特黄特色大片∵黄 | 欧美一级毛片国产一级毛片 | 国产精选第一页 | 国产亚洲精品色一区 | 精品欧美一区二区在线观看欧美熟 | 在线播放日本爽快片 | 欧美日韩亚洲综合久久久 | 不卡一区二区在线 | 特黄一级片 | 国产欧美日韩精品a在线观看 | 日韩中文字幕网站 | 91福利国产在线在线播放 | 国产精品免费看 | 在线日韩| 激情欧美一区二区三区 | 精品99一区二区三区麻豆 | 99爱在线精品视频免费观看9 | 国产高颜值露脸在线观看 | a级片在线看 | 亚洲狠狠婷婷综合久久久久 | 亚洲欧美日韩成人网 | 国产黄色免费观看 | 国产精品国产精品 |