Search code examples
emailamazon-ec2web-hostingubuntu-server

One domain multiple servers


I have a domain mydomain.com

I need to use this domain on multiple servers. I have greengeeks shared hosting as well as AWS with few EC2 machines for my web applications.

mydomain.com is hosting a marketing site via greengeeks hosting and it also provides my email server.

I want one sub domain app.mydomain.com that will point to one of my ec2 instance, another subdomain appadmin.mydomain.com point to another ec2 instance, What is the best way to setup domains and sub-domains like this. (currently i am using different domain (mydomain.org) for my aws instance, which isn't elegant)

As my mail server is on greengeeks, and I programatically send email from my ec2 app server using an email id [email protected], some email clients shows warning as "cannot verify email origin" and some pushes it in spam folder, is there a solution to it, I read about MX and SPF record but I am confused how to create them and where to put them.

Thanks, K


Solution

  • I want one sub domain app.mydomain.com that will point to one of my ec2 instance, another subdomain appadmin.mydomain.com point to another ec2 instance, What is the best way to setup domains and sub-domains like this. (currently i am using different domain (mydomain.org) for my aws instance, which isn't elegant)

    I'm not sure what the question is about. You should be able to make an a-record for each site. One for app.mydomain.com and another appadmin.mydomain.com.

    As my mail server is on greengeeks, and I programatically send email from my ec2 app server using an email id [email protected], some email clients shows warning as "cannot verify email origin" and some pushes it in spam folder, is there a solution to it, I read about MX and SPF record but I am confused how to create them and where to put them.

    SPF records are made typically made in either TXT-records, or SPF-records if your DNS provider, has a specific section for this. Both should work.

    TXT records are nothing more than a record, with some text in it, but it can be interpeted as a SPF record, if specified as one (see part 1).

    SPF entries are a collection of trusted IPs/hosts, that a spamfilter or mailserver can use to validate a the IP adress of the sender.

    In the email message header, it will always say where the email was sent from(cant be spoofed to my knowledge). A spamfilter will compare the sender to the SPF entries of the specific domain and decide weather to reject the message or accept it.

    Lets look at one example.

    v=spf1 include:1.mailserver.com include:2.mailserver.com ip4:99.99.99.99 include:relay.anothermailserver.com ?all
    

    Part 1

    Specifies the version of SPF that you're using. SPFv1 should be able to do the trick for you.

    v=spf1
    

    Part 2

    You specify the mailservers/IP subnets that should be allowed to send from your domain.

    include:1.mailserver.com
    
    include:2.mailserver.com
    
    ip4:99.99.99.99
    
    include:relay.anothermailserver.com
    

    Part 3

    Specifies weather to mark message as (~)SoftFail, (-)HardFail, (+)Pass or (?)Neutral, when the sender is not specified in your entries.

    The receiving mailserver decides, weather to reject or accept a message based on their own policy. Meaning that some spamproviders/mailservers will reject a softfail, and some still may accept it.

    Generally a hardfail should get rejected.

    ?all
    

    If you need some material on this subject, id sugest www.openspf.org/SPF_Record_Syntax for the syntax.

    Also you can use mxtoolbox.com which has a great tool, that specifies the different parts of a record.

    As for the MX records. The MX specifies the receiving mailserver and in which order it should try to send the messages to them.

    Example

    Sending a mail to [email protected]

    MX record for mydomain.com
    Priority = 10 / 99.99.99.99
    Priority = 20 / server1.mymailserver.com
    Priority = 30 / server2.mymailserver.com
    Priority = 5 / myloadbalancer.mymailserver.com
    

    Here it will look up the MX-records for mydomain.com, find the MX with the lowest priority and send the message to that IP/Host. If it doesnt get an answear from the server, it will proceed to try and send to the next MX-entry. If the message is accepted by receiving mailserver, then the mail goes through. If no answer is given by any of the MX-entries, it will notify the sender address, that the message could not be sent.

    Please let me know if i missed something.

    /AG