I have a web-server written in CPP. I want to determine the server-type of the request. i.e whether the request came from http or https URL ?
If you have your own web-server written in c++ you already know whether it came over http or https as they come through different ports and require different handling.
Which port you're listening to?
By default HTTPS URLs begin with "https://" and use port 443 by default, where HTTP URLs begin with "http://" and use port 80 by default.
There are other questions like how you're managing certificates to serve secure connections?
This article might be helpful - http://java.sun.com/developer/technicalArticles/Security/secureinternet/
Related
How do I determine (using c++ and winsock) the site protocol based on the URL, for example (www.google.com) if the protocol is not known in advance?
Or how do I determine web server TCP port?
I want do an HTTP get request using the link which after www. and need to determine the port or protocol, in order to use http over tls or simple http.
You can't. You decide the protocol you're going to use to contact some server. If you haven't decided it, you don't know it. Certainly your computer can't tell you what it will be.
It's like asking a supermarket cashier what you're going to buy today. They don't know that. You are supposed to tell them that.
What you can do is to see whether a website on that server automatically redirects HTTP traffic to a HTTPS URI (thus enforcing SSL), or otherwise blocks non-HTTPS traffic. If that's what you want to do, you can achieve it by attempting to make an HTTP connection to that domain and see what happens.
Depending on your web browser make/model/version, that may be what it is doing when you enter "www.google.com" without specifying a protocol: assuming http:// then following any remote redirects that take you to https:// instead. Pretty soon, though, or already if you have certain extensions installed, the default is going to be https://. I must stress though, again, that this is still the client (i.e. the browser) making the decision, not the server; if you are writing your own browser then, again, you must choose what that default should be.
In your example, www.google.com is a domain name.
To get protocol you need full urls like
https://www.google.com or http://www.google.com
In the above example, http and https are protocol types.
You can also use nmap to determine the open ports, service name and protocol used
I'm trying to connect to a domain that seems to have Akamai tech.
I can't connect and nor does curl - but the browser does.
So I assume the IP address is not blocked.
Reading up - it seems that Akamai runs some algorithms and doesn't allow connections sometimes.
But since a web browser works (from same pc) - I assume it can be made to work.
Any tip?
Your question is quite wage. Akami WAF will not allow curl unless you have white-listed your IP address. Browser connect is just TCP connection on port 80, 443. Which http method did you try to access and is that method allowed? By default i believe only GET and POST are allowed.
I write a simple web server. At this stage I had already written requests will support protocol http. Now I want to add https.
Here is a resource from which I took as an example http server.
Here I look at the example https server.
As you can see all the keys and certificates is established immediately . But I need to get for each site they were different . Correspondingly, they should be set after the header processing .
Also with the example number 1 that inherit from HttpDaemon QTcpServer. And with Example 2 SSLServer inherit from QTcpServer. Both have a method void incomingConnection (int). So I can not understand how my server determined use https or http ( The answer probably lies in the method paramatre incomingConnection? In the example it is int, and the second quint16. But I doubt it. )
I need you to different sites running on my server had different https certificate. And at the same time to work with them on sites http.
I've just started studying Winsocks and I've a simple question for you: how can I determine if the connection to a server must take place over a HTTP or HTTPS connection?
Let's say I want to connect to randomsite.random, how can I know what kind of connection I need? I know that for HTTP I must connect to port 80, while for HTTPS is needed 443, but how can I determine WHEN is needed a HTTPS connection?
Thank you for the attention!
The same way a web browser decides: Based on the URL you are trying to load. In a web browser, the URL begins with http or https, which is used to determine whether an SSL connection should be used. This is also used to determine the port if no port number is specified in the URL.
Many sites offer both a secure and a non-secure version. Some offer only a secure version, but still run a non-secure server which issues a redirect to the URL of the secure version. If you implement following of redirects, you don't need to worry about which version to use: it will happen automatically.
This is usually a function of the site you are connecting to.
If the site requires a HTTPS connection, then if you connect over HTTP you will get a redirect response code with a HTTPS URL.
Firstly, it's not always port 80 and port 443. Secondly, you won't establish successful communication if you use the wrong communication protocol. As said in another answer, if you try to connect via HTTP to an HTTPS server, it will give you a redirect response code with an HTTPS URL.
Most of the time, you have this information before-hand!
Question moved to Serverfault ( https://serverfault.com/questions/346125/ssl-error-rx-record-too-long-ff-django-startssl-windows )
Feel free to delete this on if that's more appropriate (I don't know what the convention is).
(That's a question for ServerFault more than StackOverflow.)
If I understand correctly, you've set up Django with SSL on port 8082 and without SSL on port 8081.
It's often not necessary to secure the communication between the Apache Httpd server and the server behind ProxyPass, from localhost to localhost. You could simply use ProxyPass http://127.0.0.1:8081/.
Alternatively, if you really want to use SSL/TLS for the communication to the backend (typically, if the server in the back is remote), you'd need to use ProxyPass https://127.0.0.1:8082/ (https) and set the SSLProxy* directives (see mod_proxy summary).