Welcome! Log In Create A New Profile

Advanced

Re: stripping www and forcing ssl

Gena Makhomed
March 20, 2015 02:58PM
On 20.03.2015 20:01, David Benfell wrote:

> I am attempting to strip www. and force SSL. Here are the blocks I'm
> using:
>
> server {
> listen 50.250.218.168:80;
> listen 50.250.218.168:443 ssl;
> listen [2001:470:67:2b5::10]:80;
> listen [2001:470:67:2b5::10]:443 ssl;
>
> server_name www.disunitedstates.org;
> include ssl_common;
>
> access_log
> /var/log/nginx/disunitedstates.org/access.log;
> error_log
> /var/log/nginx/disunitedstates.org/error.log;
>
> return 301 https://disunitedstates.org$request_uri;
> }
>
> server {
> listen 50.250.218.168:80;
> listen [2001:470:67:2b5::10]:80;
>
> server_name disunitedstates.org;
>
> access_log
> /var/log/nginx/disunitedstates.org/access.log;
> error_log
> /var/log/nginx/disunitedstates.org/error.log;
>
> return 301 https://disunitedstates.org$request_uri;
> }
>
> I have a separate server block for actually serving the site.
>
> But when one tries to access http://disunitedstates.org, one gets a
> 400 error, "The plain HTTP request was sent to HTTPS port." The
> information I'm finding out on the web about this is confusing and
> contradictory.
>
> How should this be done?

Probably "include ssl_common;" contains "ssl on;"
directive, which forces nginx to use HTTPS on 50.250.218.168:80

http://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl

Just remove "ssl on;" from ssl_common include file and reload nginx.

--
Best regards,
Gena

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

stripping www and forcing ssl

David Benfell March 20, 2015 02:02PM

Re: stripping www and forcing ssl

B.R. March 20, 2015 02:38PM

Re: stripping www and forcing ssl

Gena Makhomed March 20, 2015 03:02PM

Re: stripping www and forcing ssl

Gena Makhomed March 20, 2015 02:58PM

SOLVED: Re: stripping www and forcing ssl

David Benfell March 21, 2015 02:10AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 252
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready