国产成人精品久久免费动漫-国产成人精品天堂-国产成人精品区在线观看-国产成人精品日本-a级毛片无码免费真人-a级毛片毛片免费观看久潮喷

您的位置:首頁技術文章
文章詳情頁

Nginx主機域名配置實現

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

一、配置多個端口訪問不同文件

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

#兩個不同文件夾,分別存放不同文件[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的站點指向一個文件夾,再復制這個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;    }}}

#瀏覽器訪問

二、配置不同域名訪問不同文件

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

#四個文件夾,分別對應不同文件內容

[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;    }}#正則表達式域名    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

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

#訪問結果

sever_name匹配順序:

  • 精準匹配
  • 通配符開頭,比如*.example.com
  • 通配符結尾,比如www.example.*
  • 正則表達式
  • 默認值

三、配置不同域名訪問同個文件

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

[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再添加一個域名,不需要在復制一個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

#該宿主機的host文件

#訪問結果如下:

到此這篇關于Nginx主機域名配置實現的文章就介紹到這了,更多相關Nginx主機域名配置內容請搜索以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持!

標簽: Nginx
主站蜘蛛池模板: 国产欧美在线观看不卡 | 国产一区二区三区影院 | freexxxx性特大另类ww | 中国国产成人精品久久 | 国产亚洲欧美在线播放网站 | 日韩一区二区免费看 | 久久国产精品久久 | 国内自拍偷拍视频 | 国产精品午夜免费观看网站 | 亚洲欧美日韩另类精品一区二区三区 | 日本免费大黄在线观看 | 在线看片亚洲 | 国产一级aaa全黄毛片 | aa大片成人免费网站 | 国产一区二区三区影院 | 永久免费不卡在线观看黄网站 | 91年精品国产福利线观看久久 | 性盈盈影院在线观看 | 真正免费一级毛片在线播放 | 最新国产精品好看的国产精品 | 萝控精品福利视频一区 | 免费国产视频在线观看 | 国产成人亚洲合集青青草原精品 | 在线视频 一区二区 | 日韩一区二区三区视频 | 亚洲国产成人久久综合一区 | 老少配性xxxxxx | 欧美日本一区视频免费 | 国产福利在线91 | 日韩黄在线观看免费视频 | 亚洲精品xxxxx | 日韩三级中文字幕 | 国产精品亚洲第一区柳州莫青 | 美女很黄很黄是免费的·无遮挡网站 | 国产欧美日韩综合精品无毒 | 久久福利青草精品资源 | 国产精品第五页 | 亚洲视频一区二区三区 | 国产精品午夜性视频网站 | 另类专区欧美 | 久草在线免费资源站 |