婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > docker nginx實現一個主機部署多個站點操作

docker nginx實現一個主機部署多個站點操作

熱門標簽:新鄉牧野400電話申請 智能電銷機器人真的有用么 高德地圖標注足跡怎么打標 企業辦理400電話收費標準 激光標記地圖標注 百度地圖底圖標注 中國地圖標注上各個省 撫州市城區地圖標注 電銷智能機器人試用

在某站租賃的虛擬機快到期了,續費得花200多,想到在阿里云新買的服務器,不如把這個也轉移過去。域名我就用真實的吧,大家別黑我網站就好了,謝謝各位了。

阿里云里面已經用部署了一個站點 用域名 www.dcssn.com 就能直接訪問,我的想法是再用 www.xhxf119.com 指向這個主機,根據域名的不同去訪問不同的服務。

首先

域名解析都要指向這個主機的ip

然后

www.dcssn.com的服務開啟8080端口,docker run -p 8080:80 weian

www.xhxf119.com的服務開啟8081端口,docker run -p 8081:80 xinhua

用www.dcssn.com:8080 能正常訪問 www.xhxf119.com:8081也能正常訪問

接下來 寫nginx的配置文件

nginx.conf
worker_processes 1;
events {
 worker_connections 1024;
}
http {
 include  mime.types;
 default_type application/octet-stream;
 sendfile  on;
 keepalive_timeout 65;
 server
 {
  listen 80;
  server_name www.dcssn.com;
  location / {
  proxy_redirect off;
  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_pass http://47.92.69.112:8080;
  }
 }
 
 server
 {
  listen 80;
  server_name www.xhxf119.com;
  location / {
  proxy_redirect off;
  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_pass http://47.92.69.112:8081;
  }
 }
}

然后把這個文件保存到/host/path/ 目錄下

docker run --name my-custom-nginx-container -v /host/path/nginx.conf:/etc/nginx/nginx.conf:ro -d -p 80:80 nginx

大概流程就是這樣了 就可以直接輸入 www.dcssn.com 或者 www.xhxf119.com 訪問了

補充知識:docker配置nginx支持多個子域名對應不同的項目目錄

有機會要弄一個反向代理分發

具體的php與nginx配置請看本人博客里的搭建

cd /root/nginx/conf/conf.d

vim runoob-test-php.conf

runoob-test-php.conf文件內容,其實就是子域名對應目錄就行

server {
 listen  80;
 server_name www.liuyuanshan.top;

 location / {
  #proxy_pass http://106.52.36.65:80;
  root /usr/share/nginx/html;
  index index.php index.html index.htm;
 }

 error_page 500 502 503 504 /50x.html;
 location = /50x.html {
  root /usr/share/nginx/html;
 }

 location ~ \.php$ {
  fastcgi_pass php:9000;
  fastcgi_index index.php;
  fastcgi_param SCRIPT_FILENAME /var/www/html/$fastcgi_script_name;
  include  fastcgi_params;
 }
}

server {
 listen  80;
 server_name message.liuyuanshan.top;

 location / {
  root /usr/share/nginx/html/message/;
  index index.php index.html index.htm;
 }

 error_page 500 502 503 504 /50x.html;
 location = /50x.html {
  root /usr/share/nginx/html;
 }
 location ~ \.php$ {
  fastcgi_pass php:9000;
  fastcgi_index index.php;
  fastcgi_param SCRIPT_FILENAME /var/www/html/message/$fastcgi_script_name;
  include  fastcgi_params;
 }
}


server {
 listen  80;
 server_name wordpress.liuyuanshan.top;

 location / {
  root /usr/share/nginx/html/wordpress/;
  index index.php index.html index.htm;
 }

 error_page 500 502 503 504 /50x.html;
 location = /50x.html {
  root /usr/share/nginx/html;
 }
 location ~ \.php$ {
  fastcgi_pass php:9000;
  fastcgi_index index.php;
  fastcgi_param SCRIPT_FILENAME /var/www/html/wordpress/$fastcgi_script_name;
  include  fastcgi_params;
 }
}

重啟docker的nginx容器

docker restart ngixn

以上這篇docker nginx實現一個主機部署多個站點操作就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持腳本之家。

標簽:西安 臨汾 辛集 延安 海西 南通 邯鄲 忻州

巨人網絡通訊聲明:本文標題《docker nginx實現一個主機部署多個站點操作》,本文關鍵詞  docker,nginx,實現,一個,主機,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《docker nginx實現一個主機部署多個站點操作》相關的同類信息!
  • 本頁收集關于docker nginx實現一個主機部署多個站點操作的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 开封市| 西安市| 从江县| 宁蒗| 获嘉县| 安仁县| 青铜峡市| 怀宁县| 武鸣县| 江北区| 麟游县| 小金县| 盐亭县| 锦州市| 嵊州市| 松江区| 奉新县| 石城县| 宜春市| 阿合奇县| 碌曲县| 麻栗坡县| 大余县| 鹤庆县| 图木舒克市| 乌什县| 余姚市| 来凤县| 林甸县| 德安县| 滨海县| 兴化市| 呼图壁县| 定边县| 文水县| 轮台县| 海伦市| 楚雄市| 红桥区| 锡林浩特市| 德钦县|