Https with runserver

196 views
Skip to first unread message

Simon Bächler

unread,
Sep 14, 2011, 8:05:49 AM9/14/11
to Django users
Any news considering HTTPS and runserver?

I tried the stunnel method but I get the message: Line 5: End of
section https: SSL server needs a certificate.
Stunnel also complains about the openssl version. I have 0.9.8r
installed. The build of 1.0 fails on OSX.

When I then try to access the page I get the error: (Fehlercode:
ssl_error_rx_record_too_long).

I need the https connection for local Facebook development.

Regards
Simon

Russell Keith-Magee

unread,
Sep 14, 2011, 7:44:42 PM9/14/11
to django...@googlegroups.com
2011/9/14 Simon Bächler <s...@feinheit.ch>:

> Any news considering HTTPS and runserver?

What "News" are you expecting?

The Django project has made no secret of the fact that we don't
consider runserver to be a "real" webserver. It isn't intended for
production use. We haven't spent any time or effort auditing it for
production use. It is missing many key features that a "real"
webserver needs to have.

runserver is intended to be the bare minimum necessary to support
local development. If you have nontrivial needs, you should be looking
at alternative options for local development.

Yours,
Russ Magee %-)

Aljoša Mohorović

unread,
Sep 14, 2011, 8:17:16 PM9/14/11
to django...@googlegroups.com
if you need to simulate https for development, like for facebook apps,
you can setup apache proxy.
something like:

<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ProxyPass / http://localhost:8000/ retry=1
ProxyPassReverse / http://localhost:8000/
ProxyPreserveHost On

ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/ssl_access.log combined

SSLEngine on
SSLCertificateFile /etc/ssl/certificate.crt
SSLCertificateKeyFile /etc/ssl/example.com.key
SSLCertificateChainFile /etc/ssl/intermediate.crt
BrowserMatch "MSIE [2-6]" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
# MSIE 7 and newer should be able to use keepalive
BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
</VirtualHost>
</IfModule>

Gelonida N

unread,
Sep 14, 2011, 8:52:29 PM9/14/11
to django...@googlegroups.com
On 09/15/2011 01:44 AM, Russell Keith-Magee wrote:
> 2011/9/14 Simon B�chler <s...@feinheit.ch>:
You can also create a minimalist https server with python twisted
(and the openssl module)

You just need additional url rules, such, that django is also serving
/static amd /media directories:


just set PYTHONPATH
and
DJANGO_SETTINGS_MODULE
as needed,

create a file named django_wrapper.py with following contents:
# ######## File starts here ##################
from django.core.handlers.wsgi import WSGIHandler

application=WSGIHandler()
# ############ end of file #############

and call then

twistd -n web --https $HTTPS_PORT -p $HTTP_PORT \
--certificate yourcert.crt --privkey your_cert.key \
--wsgi django_wrapper.application

Bjarni Rúnar Einarsson

unread,
Sep 22, 2011, 10:06:13 AM9/22/11
to django...@googlegroups.com
Another way, would be to use PageKite. The service provides a wildcard
SSL cert for all *.pagekite.me names. From the command line:

curl http://pagekite.net/pk/pagekite-0.4.py >pagekite.py
python pagekite.py 8000 yourname.pagekite.me

Answer the account creation questions and then go to
https://yourname.pagekite.me/ - whatever is on port 8000 should be
visible. If you want to quickly password protect it so your dev work
isn't open to the world, do this instead:

python pagekite.py 8000 yourname.pagekite.me +password/user=secret

(disclaimer: I made this! I love feedback. :-)

On Thu, Sep 15, 2011 at 12:52 AM, Gelonida N <gelo...@gmail.com> wrote:
> On 09/15/2011 01:44 AM, Russell Keith-Magee wrote:

>> 2011/9/14 Simon Bächler <s...@feinheit.ch>:

> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to django-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
>
>

--
Bjarni R. Einarsson
Founder, lead developer of PageKite.

Make localhost servers visible to the world: http://pagekite.net/

Bjarni Rúnar Einarsson

unread,
Sep 22, 2011, 11:53:38 AM9/22/11
to django...@googlegroups.com
Following up to myself (sorry for the spam) - please replace
"yourname" with something you invented yourself. Everyone signing up
for yourname.pagekite.me is really not going to work very well. :-)

2011/9/22 Bjarni Rúnar Einarsson <b...@pagekite.net>:

Reply all
Reply to author
Forward
0 new messages