I have an ubuntu 12.04 server with nginx and ispconfig3. I have installed an ssl too. The domain name is www.surf-anonymous.info My problem is that when I enter in the address bar www.surf-anonymous.info, then the browser takes me to the NGINX index.html file stored in the /usr/share/nginx/www directory. When I enter http://surf-anonymous.info/ or https://surf-anonymous.info/ then it takes me to the ISPConfig directory : /var/www/clients/client1/web2 How can I make all 3 prefixes (www, http, https) point to the same place?
ok, this worked, they all go now to the ISPConfig directory : /var/www/clients/client1/web2. Now my problem is that I can see on the address 3 different versions of the domain name: www.surf-anonymous.info, http://surf-anonymous.info/, https://surf-anonymous.info/ If it was Apache, then I could try to make the redirections through the .htaccess file. Now with NGinx what would you suggest me to do?
I went to ISPConfig -> Web Domain -> Redirect tab and I set Redirect Type : Permanent Redirect Path : https://surf-anonymous.info/ SEO Redirect : *.domain.tld -> domain.tld Now the redirections work like this: www.surf-anonymous.info -> http://surf-anonymous.info/ http://surf-anonymous.info/ -> http://surf-anonymous.info/ https://surf-anonymous.info/ -> https://surf-anonymous.info/ How can I make all redirect to https://surf-anonymous.info/ ?
Add a htaccess to your surf-anonymous.info domain that redirects all http to https: Code: RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
Maybe you can try something like this in the nginx vhost (didn't test!) Code: if ($ssl_protocol = "") { rewrite ^ https://$server_name$request_uri? permanent; }
After making some other changes, now the redirections work like this: www.surf-anonymous.info -> https://surf-anonymous.info/ http://surf-anonymous.info/ -> http://surf-anonymous.info/ https://surf-anonymous.info/ -> https://surf-anonymous.info/ So now I need to make the http -> https redirection. According to this (http://serverfault.com/questions/67...https-while-maintaining-sub-dom/171238#171238), the solution is this code: Code: server { listen 80; return 301 https://$host$request_uri; } I guess this goes to the vhost file. So I checked my /etc/nginx/sites-available/surf-anonymous.info.vhost file. Some of the contents appear to be writen by ispconfig3: Code: server { listen *:80; listen *:443 ssl; ssl_certificate /var/www/clients/client1/web2/ssl/www.surf-anonymous.info.crt; ssl_certificate_key /var/www/clients/client1/web2/ssl/www.surf-anonymous.info.key; server_name surf-anonymous.info www.surf-anonymous.info; root /var/www/surf-anonymous.info/web; if ($http_host ~* "^(.+)\.surf-anonymous\.info$") { rewrite ^ $scheme://surf-anonymous.info$request_uri? permanent; } if ($http_host != "surf-anonymous.info") { rewrite ^(?!/\b(stats|error)\b)/(.*)$ https://surf-anonymous.info/$2 permanent; } index index.html index.htm index.php index.cgi index.pl index.xhtml; So it seems to me that I need to add this single line : Code: return 301 https://$host$request_uri; But where exactly do I place it?
I changed the vhost file, so that the beginning is like this: Code: server { listen 80; server_name surf-anonymous.info www.surf-anonymous.info; return 301 https://surf-anonymous.info$request_uri; } server { listen 443 ssl; server_name surf-anonymous.info www.surf-anonymous.info; ssl_certificate /var/www/clients/client1/web2/ssl/www.surf-anonymous.info.crt; ssl_certificate_key /var/www/clients/client1/web2/ssl/www.surf-anonymous.info.key; root /var/www/surf-anonymous.info/web; The solution works and now everything redirects to HTTPS. QUESTION: Shouldn't this be done from inside ISPConfig?