在Nginx上设置子域? [英] Setting up subdomains on nginx?

查看:73
本文介绍了在Nginx上设置子域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在nginx上设置一个子域.我的设置是在端口8080上运行并使用nginx代理的Pylons应用.

I'm trying to set a subdomain on nginx. My setup is a Pylons app running on port 8080 and using proxy from nginx.

我试图让子域正常工作的原因是最终要设置开发和登台服务器.

The reason why I'm trying to get subdomains to work is to eventually set up dev and staging servers.

这是我的nginx.conf文件:

Here is my nginx.conf file:

worker_processes  2;

events {
    worker_connections  1024;
}


http {
    include     mime.types;
    default_type    application/octet-stream;
    access_log  logs/rentfox.access.log;
    error_log   logs/rentfox.error.log;
    gzip        on;
    sendfile    on;
    tcp_nopush  on;
    tcp_nodelay on;
    keepalive_timeout   75 20;

    server {
        listen       80;
        server_name  xxx.net;

        location / {            
            include /usr/local/nginx/conf/proxy.conf;
            proxy_pass http://127.0.0.1:8080;
            proxy_redirect default;
            root /var/apps/xxx/xxx/public/;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

    }
    server {
        listen       80;
        server_name  dev.xxx.net;

        location / {            
            include /usr/local/nginx/conf/proxy.conf;
            proxy_pass http://127.0.0.1:8080;
            proxy_redirect default;
            root /var/apps/xxx/xxx/public/;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

    }

}

提前谢谢!

推荐答案

我可以看到xxx.net& www.xxx.net域,但是在尝试dev.rentfox.net域时却找不到服务器-您是否使用通配符或dev子域设置了DNS记录?

I can see the xxx.net & www.xxx.net domains but I get a sever not found when I try the dev.rentfox.net domain - do you have the DNS records set up with a wildcard or with the dev sub-domain?

如果DNS设置正确,当您访问dev子域时,nginx的访问和错误日​​志会是什么样?

If the DNS is set up properly what do the access and error logs from nginx look like when you access the dev sub-domain do they have any entries in them?

这篇关于在Nginx上设置子域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆