導航:首頁 > IDC知識 > windowsnginx多域名配置

windowsnginx多域名配置

發布時間:2020-12-14 07:59:40

1、在nginx環境下一個ip如何配置多個域名

你好,不管是IIS還是nginx,都是用主機頭實現,詳細可參閱:
http://www.cnblogs.com/kuyuecs/archive/2012/07/12/2588025.html

2、nginx怎麼配置,才能在一個伺服器上,一個域名,多個應用同時運行!

一個伺服器上部署多份的話是用報頭區分就成了;只有一個域名的話那可以用埠區分,域名也有別名

3、nginx 反向代理一個server下配置多個location域名問題

這樣的用法,當然只能到第一個的,要這樣用
在http節點中加入這個,server的具體值你自已改
upstream cjdby{
server pigoss;
server tianyuan;
}
在server節點中,只保留一下location,然後把proxy_pass改成這樣

proxy_pass http://cjdby;
其它的set_header不變

4、linux中nginx如何配置一個ip多個域名

nginx綁定多個域名可又把多個域名規則寫一個配置文件里,也可又分別建立多個域名配置文件,我一般為了管理方便,每個域名建一個文件,有些同類域名也可又寫在一個總的配置文件里。
一、每個域名一個文件的寫法
       首先打開nginx域名配置文件存放目錄:/usr/local/nginx/conf/servers ,如要綁定域名www.rodine.org 則在此目錄建一個文件:www.rodine.org.conf然後在此文件中寫規則,如:server

{
listen 80;
server_name www.rodine.org; #綁定域名
index index.htm index.html index.php; #默認文件
root /home/www/rodine.org; #網站根目錄
include location.conf; #調用其他規則,也可去除
}

然後重起nginx伺服器,域名就綁定成功了nginx伺服器重起命令:/etc/init.d/nginx restart
二、一個文件多個域名的寫法
一個文件添加多個域名的規則也是一樣,只要把上面單個域名重復寫下來就ok了,如:

server
{
listen 80;
server_name www.rodine.org; #綁定域名
index index.htm index.html index.php; #默認文件
root /home/www/rodine.org; #網站根目錄
include location.conf; #調用其他規則,也可去除
}server
{
listen 80;
server_name msn.rodine.org; #綁定域名
index index.htm index.html index.php; #默認文件
root /home/www/msn.rodine.org; #網站根目錄
include location.conf; #調用其他規則,也可去除
}

三、不帶www的域名加301跳轉
如果不帶www的域名要加301跳轉,那也是和綁定域名一樣,先綁定不帶www的域名,只是不用寫網站目錄,而是進行301跳轉,如:

server
{
listen 80;
server_namerodine.org;
rewrite ^/(.*) http://www.rodine.org/$1 permanent;
}

四、添加404網頁

       添加404網頁,都可又直接在裡面添加,如:

server
{
listen 80;
server_name www.rodine.org; #綁定域名
index index.htm index.html index.php; #默認文件
root /home/www/rodine.org; #網站根目錄
include location.conf; #調用其他規則,也可去除
error_page 404 /404.html;
}

學會上面四種規則方法,基本就可以自己獨立解決nginx 多域名配置問題了

5、nginx多域名,多子站如何配置

nginx中,每個server塊代表一個或多個站點
server塊中的server_name用於區分站點
如果站點內容完全相同,只是域名不同,則可以在server_name後追加域名
如果站點之間沒有關聯,則追加一個server塊 ,然後配置server_name以及其他站點信息

6、如何配置nginx 同一ip,多域名,不同埠

類似這樣子

server { 
listen       80; 
server_name  A.ABC.com; 
location / { 
proxy_pass http://localhost:1234; 
proxy_set_header   Host    $host; 
proxy_set_header   X-Real-IP   $remote_addr; 
proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for; 
   } 
}

另外一個:

server { 
listen       80; 
server_name  B.ABC.com; 
location / { 
proxy_pass http://localhost:4321; 
proxy_set_header   Host    $host; 
proxy_set_header   X-Real-IP   $remote_addr; 
proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for; 
   } 
}

這樣就可以把兩個請求轉發到對應的本地程序埠上了。。。 :)

7、nginx配置多應用,但是只有一個應用有域名,怎麼配置

為其他沒有域名的應用監聽不同的埠,通過ip:埠的方式訪問

如果伺服器有多個IP地址,為其他應用監聽不同的IP,通過訪問不同的ip來訪問不同的應用!

8、nginx 文件配置 如何設置域名

1.路徑:  /etc/nginx/nginx.conf 和 /etc/nginx/conf.d,

其實只有/etc/nginx/nginx.conf 這一個配置文件,因為在nginx.conf中,其他配置文件都是可以利用 include 指令·引入的

部分配置文件:

server
{
listen 80;
server_name test.net;

root  /var/www/test;#include none.conf;
#error_page 404 /404.html;
location ~ [^/].php(/|$)
{
include  fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index  index.php;
client_max_body_size  500m;
}

location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$
{
expires  30d;
}

location ~ .*.(js|css)?$
{
expires  12h;
}
#location = /HBLS.deb {
# rewrite . /HBLS.deb;
# default_type application/x-deb;
#}
access_log off;
#access_log  logs/lung.access.log;
#error_log  logs/lung.error.log  debug;
}

9、nginx同域名配置多目錄路徑

server{
server_name xxx.cn;
charset utf-8;
location / {
index index.html index.shtml;
root /web/t; 新路徑
error_page 404 = @not_found;
}

location @not_found {
index index.html index.shtml;
root /web1/t; 老路徑
}

}

與windowsnginx多域名配置相關的知識