Jump to content

How to disable HTTP port?


Tokay

Recommended Posts

If you want to close port 80 totally, you can do it on the server's firewall.

If not, you can redirect port 80 calls to the SSL port if you run the app as a DLL, e.g for apache:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L] 

I'm sure you can do the same thing for IIS.

Link to comment
Share on other sites

hi

If for IIS  you can use URL Rewrite to do it

first you have to download it and install it on your IIS Server, It is an extension from Microsoft for IIS

https://www.iis.net/downloads/microsoft/url-rewrite

you can find many videos on how to use it or flow these steps

https://www.namecheap.com/support/knowledgebase/article.aspx/9953/38/iis-redirect-http-to-https

regards

  • Like 1
Link to comment
Share on other sites

  • 8 months later...

Up. I want to do it on the UniGUI side, I don't want to set any dummy port for later disable it :)

It has very simple solution (when sources is accessible, but we unfortunatelly has no sources, and have to bother support).

Just bind one port and use same port for https connections and that's all:

 IdHTTPServer1.Bindings.Add.Port := HTTPPort;

procedure TWebDataModule.IdHTTPServer1QuerySSLPort(APort: word; var VUseSSL: boolean);
begin
 VUseSSL := APort = HTTPPort;
end;
 

That's all.

Link to comment
Share on other sites

11 hours ago, andyhill said:

Server Options

soAutoRedirectHttps

Thanks all for reply. Does this option needs only one port? If no, then it's wrong solution for me. I need to open only one port, not both for http and https.

Link to comment
Share on other sites

25 minutes ago, Tokay said:

Thanks all for reply. Does this option needs only one port? If no, then it's wrong solution for me. I need to open only one port, not both for http and https.

Hello, Can You explain more of Your needs?

You want to disable port or just redirect to https ?

Your examples with Indy are equivalent to soAutoRedirectHttps = True

Link to comment
Share on other sites

3 hours ago, irigsoft said:

Hello, Can You explain more of Your needs?

You want to disable port or just redirect to https ?

Your examples with Indy are equivalent to soAutoRedirectHttps = True

I need only one listened port with https connection on it.

Link to comment
Share on other sites

ServerModule
UniGUIServerModuleBeforeInit

// Remove Default Project HTTP Port
Bindings.BeginUpdate;
Bindings.Clear;
Bindings.EndUpdate;

// Add HTTPS port
SSL.SSLBindings.BeginUpdate;
SSL.SSLBindings.Clear;
with SSL.SSLBindings.Add do begin
  IP:= BindToSslIP;
  Port:= SslPort;
  BroadcastEnabled:= True;
end;
SSL.SSLBindings.EndUpdate;
 

Link to comment
Share on other sites

14 hours ago, Hayri ASLAN said:

Hello

Do you want to disable http port completely or you want redirect users visited "http://yoursite" to "https://yoursite" ?

I want to disable (even don't bind) any http port. Bind any one port for https and that all.

It definitely possible in the Indy library, our 'main' web works well in such mode.

Link to comment
Share on other sites

  • 5 weeks later...
  • 4 weeks later...
On 7/21/2021 at 10:00 AM, Tokay said:

I want to disable (even don't bind) any http port. Bind any one port for https and that all.

Hello, I am sorry but I can't understand what You really want.

I am very interested in security and I want to know what the problem is. Have you tried my suggestion using UniGUIServerModuleHTTPCommand or UniGUIMainModuleHandleRequest, you can ignore all http ports, just check for data in UniSession.ARequest.Referer

If You just disable request from http:// ?

 like this on UniGUIMainModuleHandleRequest:

 

if (UniSession.ARequest.URI = '/HandleEvent')
then begin
        //redirect to https
     If POS (''http://', UniSession.ARequest.Referer) > 0 then begin

        UniSession.AResponse.ResponseNo := 308;
        UniSession.AResponse.ResponseText := 'redirected';
        UniSession.TerminateAfterSecs(2);

        //redirect to https
        //RedirectURL := StringReplace(RedirectURL, 'http://', 'https://', [rfIgnoreCase]);
        UniSession.UrlRedirect (RedirectURL);
    end;

Link to comment
Share on other sites

@tokay is that what You want

"I have hosted my site on TCP port 91. Is there a way to bind their SSL certificate on that same port 91?
I'm interpreting this question as "I'm running my site on http://www.mysite.example:91/ and I also want to run it for HTTPS at https://www.mysite.example:91/" (in which case it's not a duplicate of Multiple SSL domains on the same IP address and same port?, as temporarily marked)."

 

from here : https://serverfault.com/questions/342246/how-to-bind-website-and-its-ssl-version-using-the-same-port 

Link to comment
Share on other sites

  • 1 month later...

I've finally found solution in the manual: 'The next parameter to confgure is the SSL port. You can leave it to its default value of 0. In this case you can access your server through the port configured in ServerModule -> Port which is 8077 by default.'. Sorry for annoyance.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...