www pointing to an ip and any subdomain to another ip

0

I have an application that works with wildcard DNS. So any subdomain is valid. For example:

test.domain.com other.domain.com

Any of the above links goes for a given IP.

It turns out that I want to create a wordpress site for this my application and it will work in the URL www.domain.com

Currently my DNS settings look like this:

Type A with name @ pointing to IP X
Type A with name * pointing to IP X

So I'm thinking of creating another DNS entry like this:

Type A with www name pointing to IP Y.

In my application when the person enters without for nothing, only the domain.com my application redirects to www.domain.com

I would like to know if this is the best way and if I will not make it all stop working if I do as I thought.

    
asked by anonymous 16.10.2014 / 04:26

2 answers

1

In the DNS zone it would look like this:

seudominio.ficticio     IN     A        1.2.3.4
*                       IN     A        2.2.3.4
www                     IN     CNAME    seudominio.ficticio

* I'm not considering how SOA and other parameters are, but that's the general scope.

Stop redirecting without www. for www., it is advisable to do outside of the DNS zone because within the DNS zone you can point everything to www, which would make your emails look like this @ www.yourdomain.com.

For redirection, apply to webserver resources (nginx, apache, iis, etc.).

Example, for Apache, the mod_rewrite.

    
16.10.2014 / 05:56
0

I have already done something similar using nginx , you can set up as sub-domains or even in a single url, passing through parameters.

Exemplo:
   www.meusistema.com.br/cliente1 = 192.168.1.1
   www.meusistema.com.br/cliente2 = 192.168.1.5

Here's the nginx link documentation for setting up multiple servers with different ips, so you can playing with rules or subdomain as I said.

In this case your nginx would be your IP Y, receive all requests and direct you to the correct server doing the proxy service.

I found this article with something a little like this deploy-of-several-applications-in-nginx-passenger-using-subdomain-or-suburi .

Sample file using nginx.conf

http {
    include       mime.types;
    default_type  application/octet-stream;
    server_names_hash_bucket_size  64;

    sendfile        on;
    tcp_nopush     on;

    keepalive_timeout  0;

    gzip  on;

    server {
        listen       80;
        server_name  teste.meudominio.com;
        location / {
        proxy_pass http://intancia1:8090/;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
    }
    }

    server {
        listen       80;
        server_name  producao.meudominio.com;
        location / {
        proxy_pass http://instancia0:8080/;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
    }

    #aqui vou adicionando quantos eu precisar e aponto para as maquinas que preciso

    }

}

You can do the test will not regret super simple to configure.

I hope I have helped.

    
16.10.2014 / 05:13