Basically I need for DNS to respond with different CNAMES depending if the request was made for HTTPS or HTTP object.
s.test.com -> IF(https) RESPONSE special.domain.com ELSE simple.domain.com
Is it possible? What other possible ways to do that?
Basically I need for DNS to respond with different CNAMES depending if the request was made for HTTPS or HTTP object.
s.test.com -> IF(https) RESPONSE special.domain.com ELSE simple.domain.com
Is it possible? What other possible ways to do that?
No.
DNS is not aware of HTTP or HTTPS.
Compare it to asking for secretary the phone number (IP number) for someone. You will get the same reply, no matter what you wanted to ask the person on the other end.
This isn't possible with DNS. The DNS request is completely independent of the reason for the request.
For this to be possible, the entire caching system for DNS would have to be scrapped. DNS would also have to be rewritten every time a new scheme was invented.
What are you trying to do? There might be a better way to solve your actual problem.
As everyone has mentioned, you can't do this with DNS. I think this is typically done with URL redirects. For example, if you're using Apache as your Web Server you can do set up redirect rules with mod_rewrite. Then you can write rules like:
# If HTTPS redirect to special.domain.com
RewriteCond %{HTTPS} =on
RewriteRule .* https://special.domain.com%{REQUEST_URI} [R,L]
# If not HTTPS redirct to simple.domain.com
RewriteCond %{HTTPS} !=on
RewriteRule .* http://simple.domain.com%{REQUEST_URI} [R,L]
Here are some more examples: http://www.askapache.com/htaccess/ssl-example-usage-in-htaccess.html
I'll give you the benefit of the doubt and assume that:
I therefore take your question to mean that you're wondering if there is an HTTP/HTTPS analogue in DNS to the MX (mail exchange) resource record (RR) among the resource record types supported by DNS.
This appears to be the purpose of the SRV (service) record type, described in RFC 2782. although it appears that LDAP, SIP, and XMPP services are more commonly advertised this way via DNS.
The reason for this appears to be historical: SRV records were proposed, implemented, and deployed only after HTTP was proposed, developed, and deployed. For some discussion about why it may not be a good idea to use SRV records to advertise HTTP/HTTPS at this point, see this question.
No, DNS doesn't know (or care) which protocol is requesting the lookup.
I don't know of any, but if you have control of the web server on the other end, you could redirect to a different domain (or have a different vhost) depending on whether it is using ssl or not.
As already mentioned, basic DNS does not do this. However, if you control the client (i.e., it's software that you code and distribute), you could use SRV records:
http://en.wikipedia.org/wiki/SRV_record
So if you want one response for HTTP and another for HTTPS, you would put something like the following in your DNS zone record:
_https._tcp.s.test.com. 86400 IN SRV 0 5 443 special.domain.com.
_http._tcp.s.test.com. 86400 IN SRV 0 5 80 simple.domain.com.
So a DNS client that looks for the https/tcp service for the the "s.test.com" record gets a response back saying the service is on host special.domain.com, port 443. A DNS client that asks for http/tcp for "s.test.com" gets back a response saying host simple.domain.com, port 80.
The "0 5" are priorities/preferences so that you can do round-robin if you have multiple hosts for the same service (special1, special2, ...; simpleA, simpleB, etc.).
Most software (e.g., web browsers) don't look up the SRV records, only A records.
Since you put load-balancing tag in your question, I have to mention that load-balancing by port (http is 80 and https is 443) is the easiest thing you can do.
Moreover, you can add another level of load balancing by virtualhost (http) or SNI (https).
Other than that, this question is already well-answered.
No. As others have mentioned, that is not the name server's responsibility.
However, you could modify your application to detect the protocol (HTTP or HTTPs) and provide its links accordingly.
Here's an example. Let's say you have a Web Page that displays multiple images. You may want to link these images to your HTTPs CDN when the Page is viewed using HTTPs and you may want the page to use your HTTP CDN when the page is accessed using HTTP. Use a dynamic web application to check the protocol and replace all links accordingly.