1

I am migrating my store from apache to Nginx due to memory and performance concerns. I configured vhost file for http and https, but somehow I am not able redirect http://www.domain.com/admin to https://www.domain.com/admin.

On login window, it prompts me to login and I was able to login successfully, but it doesnt redirect from http to https before login. After login it redirects to https without any certification issue.

Certificate is valid as I am able to browse normal pages in https by typing in manually.

Here is my config file:

server {
listen      80;
server_name www.domain.com domain.com;
root        /var/vhost/www/domain.com/public_html/;
index index.html index.php;

access_log /var/vhost/www/domain.com/logs/access_log;
error_log /var/vhost/www/domain.com/logs/error_log;
listen 443  ssl;
ssl_certificate /var/vhost/www/domain.com/ssl/www_domain_com_ee.crt; 
ssl_certificate_key /var/vhost/www/domain.com/ssl/domain.com.np.key;
ssl_protocols       SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers         HIGH:!aNULL:!MD5;
location / {
    try_files $uri $uri/ @handler;
    expires 30d;
}
location /app/                       { deny all; }
location /includes/                  { deny all; }
location /lib/                       { deny all; }
location /media/downloadable/        { deny all; }
location /pkginfo/                   { deny all; }
location /report/config.xml          { deny all; }
location /var/                       { deny all; }

location /var/export/ {
    auth_basic              "Restricted";
    auth_basic_user_file    htpasswd;
    autoindex               on;
}
location  /. {
    return 404;
}

location @handler {
    rewrite / /index.php;
}

location ~ .php/ {
    rewrite ^(.*.php)/ $1 last;
}

location ~ \.php$ {
    try_files $uri =404;
    expires off;
    fastcgi_read_timeout 900s;
    fastcgi_index index.php;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_param HTTPS on;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param  MAGE_RUN_CODE default; ## Store code is defined in administration > Configuration > Manage Stores
    fastcgi_param  MAGE_RUN_TYPE store;
    include /etc/nginx/fastcgi_params;
}
rewrite ^/minify/([0-9]+)(/.*.(js|css))$ /lib/minify/m.php?f=$2&d;=$1 last;
rewrite ^/skin/m/([0-9]+)(/.*.(js|css))$ /lib/minify/m.php?f=$2&d;=$1 last;

location /lib/minify/ {
    allow all;
}
gzip on;
#gzip_comp_level 9;
gzip_min_length  1000;
gzip_proxied any;
gzip_types       text/plain application/xml text/css text/js application/x-javascript;

}

Would really appreciate your help smile

Thanks

2 Answers 2

1

The trick would be to redirect all http requests to https with a return 301 https://www.domain.com

Check the Poodle proof, bulletproof Nginx SSL configuration

0

I would suggest running the backend under a subdomain (e.g. www.website.com/manage)

at which point you can create a vhost to listen for this that looks like this:

    server {
listen 80;
server_name manage.website.com;
return 301 https://manage.website.com;
}

server {
listen 443;
##SSL SETTINGS HERE##
server_name manage.website.com
#REST OF PRE-EXISTING VHOST HERE, PHP exection etc.#

}

that would do the trick, obviously replace the hash's with snippets of your existing frontend vhost.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.