导航:首页 > IDC知识 > nginx多域名

nginx多域名

发布时间:2020-08-05 22:53:35

1、如何简单的利用nginx发布多个域名

首先考虑的就是分布式、负载均衡等经常听到的It名词。那网站如何才能实现负载均衡呢,除了世面上的一些负载均衡器外,我们有哪些软件上的解决方案呢,这时候,Nginx、lvs等名词就会在脑海中浮现。那这些负载均衡的软件如何使用呢,如何读者是.net工程师,大家会选择Nginx,因为它支持Windows服务器

2、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; 老路径
}

}

3、nginx配置多应用,但是只有一个应用有域名,怎么配置

如果只有一个应用有域名,有2种方法

为其他没有域名的应用监听不同的端口,通过ip:端口的方式访问

如果服务器有多个IP地址,为其他应用监听不同的IP,通过访问不同的ip来访问不同的应用

4、nginx 多个域名 https 443只控制一个怎么弄

申请多域名SSL证书即可解决,请了解多域名SSL证书http://www.wosign.com/OVSSL/OV_ZhenSSL_MDC.htm

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

nginx中,每个server块代表一个或多个站点
server块中的server_name用于区分站点
如果站点内容完全相同,只是域名不同,则可以在server_name后追加域名
如果站点之间没有关联,则追加一个server块 ,然后配置server_name以及其他站点信息

6、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 多域名配置问题了

7、Nginx同IP绑定多域名虚拟主机没有作用。求教

建议在80端口前加上IP,免得出异常,格式 如192.168.1.10:80
你的配置没问题啊

你可能需要重启让nginx配置生效
重启之前,用 nginx -t检查一下配置文件语法。

8、在nginx环境下一个ip如何配置多个域名

你好,不管是IIS还是nginx,都是用主机头实现,详细可参阅:
http://www.cnblogs.com/kuyuecs/archive/2012/07/12/2588025.html

9、nginx 反向代理一个server下配置多个location域名问题

这样的用法,当然只能到第一个的,要这样用
在http节点中加入这个,server的具体值你自已改
upstream cjdby{
server pigoss;
server tianyuan;
}
在server节点中,只保留一下location,然后把proxy_pass改成这样

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

10、如何配置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; 
   } 
}

这样就可以把两个请求转发到对应的本地程序端口上了。。。 :)

与nginx多域名相关的知识