Luke Luke - 1 year ago 108
HTTP Question

Twisted port 80 requiring manual port 80 and not working

Throws no errors, yet silently there are problems.

When I run the usual server with python

python -m http.server 80

It works fine and I may access the server with
, but when I try running a secure twisted server with

twistd -no web --path=. --https=80 --certificate=../cert.pem --privkey=../key.pem

and try to access via a browser with
my browser can't connect and I must use
to connect.

Here's the server startup output:

twistd -no web --path=. --https=80 --certificate=../cert.pem --privkey=../key.pem
2016-11-14T17:41:47+1100 [] twistd 16.5.0 (c:\python35\python.exe 3.5.0) starting up.
2016-11-14T17:41:47+1100 [] reactor class: twisted.internet.selectreactor.SelectReactor.
2016-11-14T17:41:47+1100 [-] Site (TLS) starting on 80
2016-11-14T17:41:47+1100 [twisted.web.server.Site#info] Starting factory <twisted.web.server.Site object at 0x03028E50>
2016-11-14T17:41:47+1100 [-] Site starting on 8080

But I also can't get the normal http to server on port 80.

Here is my question now.

1) How can I get normal http to server on port 80 alongside with secure http? Maybe the answer is here?

2) How can I allow a client to connect without the trailing

3) Is it possible to allow both kinds of connections, depending on a client's request? (I know this is somehow possible as on some sites using
will take you to different places.) Perhaps the answer is maybe also here? (But port 80 cannot reuse address? Is different?)

Answer Source

HTTPS defaults to port 443, whereas HTTP defaults to port 80. The two are different protocols. Note that your HTTP server is running on 8080 as per the shown output. Since you are using a non-standard port for HTTPS, you have to specify the port explicitly.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download