[GH-ISSUE #74] https instead of http 400 Bad Request #48

Open
opened 2026-02-27 15:57:08 +03:00 by kerem · 3 comments
Owner

Originally created by @rroethof on GitHub (Nov 20, 2015).
Original GitHub issue: https://github.com/retspen/webvirtcloud/issues/74

Hi all,

Thanks for this superb and simple control tool :) (no pun intended)
I do have a small question tho, instead of using the normal http, I would like to use httpS

My settings are:

server {
    listen 80;
    server_name _ webvirtcloud.domainname.com;
    access_log /var/log/nginx/webvirtcloud-access_log;
    location / {
        rewrite ^(.*) https://webvirtcloud.domainname.com$1 permanent;
    }
}

server {
    listen 443 ssl;

    server_name webvirtcloud.domainname.com;

    access_log /var/log/nginx/webvirtcloud-ssl-access_log;

    ssl_certificate /etc/ssl/certs/wildcard.domainname.com.crt;
    ssl_certificate_key /etc/ssl/private/wildcard.domainname.com.key;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers "ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4";
    ssl_prefer_server_ciphers on;

    client_max_body_size 4M;
    client_body_buffer_size 128k;

    location /static/ {
        root /srv/webvirtcloud;
        expires max;
    }

    location / {
        proxy_pass http://127.0.0.1:8000;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-for $proxy_add_x_forwarded_for;
        proxy_set_header Host $host:$server_port;
        proxy_set_header X-Forwarded-Proto $remote_addr;
        proxy_connect_timeout 600;
        proxy_read_timeout 600;
        proxy_send_timeout 600;
        client_max_body_size 1024M;
    }

    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;

}

But when i go to the site, i get redirected to :
http://webvirtcloud.domainname.com:443/accounts/login/

:I receive a

400 Bad Request

The plain HTTP request was sent to HTTPS port
nginx/1.4.6 (Ubuntu)

any thoughts ?

Thx,
Ronny

Originally created by @rroethof on GitHub (Nov 20, 2015). Original GitHub issue: https://github.com/retspen/webvirtcloud/issues/74 Hi all, Thanks for this superb and simple control tool :) (no pun intended) I do have a small question tho, instead of using the normal http, I would like to use httpS My settings are: ``` server { listen 80; server_name _ webvirtcloud.domainname.com; access_log /var/log/nginx/webvirtcloud-access_log; location / { rewrite ^(.*) https://webvirtcloud.domainname.com$1 permanent; } } server { listen 443 ssl; server_name webvirtcloud.domainname.com; access_log /var/log/nginx/webvirtcloud-ssl-access_log; ssl_certificate /etc/ssl/certs/wildcard.domainname.com.crt; ssl_certificate_key /etc/ssl/private/wildcard.domainname.com.key; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers "ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4"; ssl_prefer_server_ciphers on; client_max_body_size 4M; client_body_buffer_size 128k; location /static/ { root /srv/webvirtcloud; expires max; } location / { proxy_pass http://127.0.0.1:8000; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-for $proxy_add_x_forwarded_for; proxy_set_header Host $host:$server_port; proxy_set_header X-Forwarded-Proto $remote_addr; proxy_connect_timeout 600; proxy_read_timeout 600; proxy_send_timeout 600; client_max_body_size 1024M; } error_page 404 /404.html; error_page 500 502 503 504 /50x.html; } ``` But when i go to the site, i get redirected to : http://webvirtcloud.domainname.com:443/accounts/login/ :I receive a ``` 400 Bad Request The plain HTTP request was sent to HTTPS port nginx/1.4.6 (Ubuntu) ``` any thoughts ? Thx, Ronny
Author
Owner

@rroethof commented on GitHub (Nov 20, 2015):

root@cloud:/etc/nginx# curl -i http://webvirtcloud.domainname.com
HTTP/1.1 301 Moved Permanently
Server: nginx/1.4.6 (Ubuntu)
Date: Fri, 20 Nov 2015 18:04:24 GMT
Content-Type: text/html
Content-Length: 193
Connection: keep-alive
Location: https://webvirtcloud.domainname.com/

<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx/1.4.6 (Ubuntu)</center>
</body>
</html>
root@cloud:/etc/nginx# curl -i https://webvirtcloud.domainname.com
HTTP/1.1 302 FOUND
Server: nginx/1.4.6 (Ubuntu)
Date: Fri, 20 Nov 2015 18:04:30 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Cookie
X-Frame-Options: SAMEORIGIN
Location: http://webvirtcloud.domainname.com:443/accounts/login/
<!-- gh-comment-id:158477567 --> @rroethof commented on GitHub (Nov 20, 2015): ``` root@cloud:/etc/nginx# curl -i http://webvirtcloud.domainname.com HTTP/1.1 301 Moved Permanently Server: nginx/1.4.6 (Ubuntu) Date: Fri, 20 Nov 2015 18:04:24 GMT Content-Type: text/html Content-Length: 193 Connection: keep-alive Location: https://webvirtcloud.domainname.com/ <html> <head><title>301 Moved Permanently</title></head> <body bgcolor="white"> <center><h1>301 Moved Permanently</h1></center> <hr><center>nginx/1.4.6 (Ubuntu)</center> </body> </html> ``` ``` root@cloud:/etc/nginx# curl -i https://webvirtcloud.domainname.com HTTP/1.1 302 FOUND Server: nginx/1.4.6 (Ubuntu) Date: Fri, 20 Nov 2015 18:04:30 GMT Content-Type: text/html; charset=utf-8 Transfer-Encoding: chunked Connection: keep-alive Vary: Cookie X-Frame-Options: SAMEORIGIN Location: http://webvirtcloud.domainname.com:443/accounts/login/ ```
Author
Owner

@rroethof commented on GitHub (Nov 20, 2015):

Have fixed this with a ugly hack for now:

    error_page 400 https://$host$request_uri;
    error_page 404 /404.html;
    error_page 497 https://$host$request_uri;
    error_page 500 502 503 504 /50x.html;
<!-- gh-comment-id:158493814 --> @rroethof commented on GitHub (Nov 20, 2015): Have fixed this with a ugly hack for now: ``` error_page 400 https://$host$request_uri; error_page 404 /404.html; error_page 497 https://$host$request_uri; error_page 500 502 503 504 /50x.html; ```
Author
Owner

@gianluca-pasqualini commented on GitHub (Mar 26, 2016):

Django needs headers to manage schema when behind a proxy so
I've solved with this

But console is not working, still getting Server disconnected (code: 1006)

Guess it's a certificate issue because I'm using a self signed one... for this I need help too.

<!-- gh-comment-id:201936905 --> @gianluca-pasqualini commented on GitHub (Mar 26, 2016): Django needs headers to manage schema when behind a proxy so I've solved with [this](http://stackoverflow.com/questions/8153875/how-to-deploy-an-https-only-site-with-django-nginx) But console is not working, still getting `Server disconnected (code: 1006)` Guess it's a certificate issue because I'm using a self signed one... for this I need help too.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/webvirtcloud#48
No description provided.