By samsambhu
I am using ‘sslserver’ in django but here not able open the url as https with out using ssl certificate
if i use “python manage.py runsslserver 0.0.0.0:9090” able to access url as https but in gunicorn, Please guide me how to do this.
description “Gunicorn daemon for Django project” start on (local-filesystems and net-device-up IFACE=eth0) stop on runlevel [!12345]
respawn
setuid root
setgid root
chdir /root
exec gunicorn
–name=zephyr
–pythonpath=zephyr
–bind=0.0.0.0:9000
–config /etc/gunicorn.d/gunicorn.py
Zephyr.wsgi:application
exec /root/myenv/bin/gunicorn --workers 3 --bind unix:/root/myproj/myproj.sock myproj.wsgi:application
upstream app_server { server 128.199.200.256:9000 fail_timeout=0; } server { listen 80; listen [::]:80 ipv6only=on; return 301 https://$host$request_uri; } server { listen 443 default_server; listen [::]:443 default_server ipv6only=on; root /usr/share/nginx/html; index index.html index.htm; client_max_body_size 4G; server_name 128.199.208.202; keepalive_timeout 5; add_header Strict-Transport-Security “max-age=31536000; includeSubdomains;”; location /media { alias /root/myproj/media; }
location /static {
alias /root/myproj/staticfiles;
}
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://app_server;
}
#ssl on; #ssl_certificate /etc/nginx/ssl/server.crt; #ssl_certificate_key /etc/nginx/ssl/server.key; } 4. sudo service nginx restart 5. gunicorn myproj.wsgi:application --bind 128.199.200.256:9000
Thanks
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
To run guicorn from the CLI in the manner you’re describing, you may need to define a --keyfile and --certfile in order for it.
Because you referenced your Nginx setup (which had these values commented out for the self-signed cert), it looks like there may be something getting mixed up in how to connect the two; I recommend looking at this sample setup for running gunicorn with Nginx:
http://docs.gunicorn.org/en/stable/deploy.html?highlight=ssl
It contains a sample configuration for a known-working configuration, which should be able to get you started.
Best,
Joseph D. Marhee Customer Success Engineer https://digitalocean.com
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.