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.