Welcome! Log In Create A New Profile

Advanced

www to non www and all to ssl

Posted by AfterDarkMike 
www to non www and all to ssl
October 07, 2011 01:46AM
First of all, great product. Love it but I want to kill it right now.

Problem: I have a domain that I want to redirect to non www and all traffic to https.

I have googled it inside out and dug through the forum.

Getting www to non www was easy enough.
Getting http to forward to https was easy enough too.
Getting https://www to forward to non www is not working for me.

Setup:

OpenVZ/Ubuntu 8.4/nginx/0.6.35

nginx.conf:

user www-data;
worker_processes 5;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;

events {
worker_connections 1024;
}

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
#sendfile on;
#tcp_nopush on;
keepalive_timeout 2;
#keepalive_timeout 65;
tcp_nodelay on;
gzip on;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}

sites-available/default:

server {
listen *:80 default;
server_name _;
access_log /var/log/nginx/localhost.access.log;
error_log /var/log/nginx/localhost.error_log warn;
root /var/www/nginx-default;
index index.php index.html;
fastcgi_index index.php;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/nginx-default;
}
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
keepalive_timeout 0;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
}
}

conf for host:

server {
server_name www.domain.com;
rewrite ^ $scheme://domain.com$request_uri redirect;
}
server {
listen 80;
server_name domain.com;
rewrite ^ https://domain.com$request_uri permanent;
}

server {
listen 443;
server_name domain.com;
access_log /var/log/nginx/domain.com.secure.access.log;
error_log /var/log/nginx/domain.com.secure.error_log warn;
root /var/www/domain.com/www;
index index.php index.html;
ssl on;
ssl_certificate /var/www/domain.com/domain.com.crt;
ssl_certificate_key /var/www/domain.com/domain_com.key;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
ssl_prefer_server_ciphers on;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/nginx-default;
}
location ~ \.php$ {
fastcgi_param HTTPS on;
include /etc/nginx/fastcgi_params;
keepalive_timeout 0;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
}
}

I have tried every different example I have seen and no matter what I can't get https://www to redirect to http://nonwww

Thanks in advance for any suggestions.
Re: www to non www and all to ssl
October 07, 2011 12:56PM
I've updated to nginx/0.8.53 and the issue persists.
Re: www to non www and all to ssl
October 07, 2011 01:15PM
That was a typo - should have been:

"I have tried every different example I have seen and no matter what I can't get https://www to redirect to https://nonwww"

AfterDarkMike Wrote:
-------------------------------------------------------
> I have tried every different example I have seen
> and no matter what I can't get https://www to
> redirect to http://nonwww
Re: www to non www and all to ssl
October 11, 2011 06:25PM
Apparently not much support here so I ended up purchasing 2 SSL certificates for www and nonwww.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 278
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