Link to home
Start Free TrialLog in
Avatar of tf2012
tf2012

asked on

SSL Plesk nginx probelm

I have a site www.fakesite.com and I have an SSL cert installed and I can navigate to https://www.fakesite.com no problem.  But I'm trying to create an nginx directive that will automatically redirect non-ssl visitors to https://www.fakesite.com

This didn't seem to work, can someone show me how to do this?

if ($server_port = 80) {
    rewrite ^ https://$host$request_uri permanent;
}
ASKER CERTIFIED SOLUTION
Avatar of gheist
gheist
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tf2012
tf2012

ASKER

I'm entering this in my nginx directive:

location / {
rewrite ^(.*)$ https://www.fakesite.com/$1 redirect;
}

and I'm getting this error:
Invalid nginx configuration: nginx: [emerg] duplicate location "/" in /var/www/vhosts/system/fakesite.com/conf/vhost_nginx.conf:9 nginx: configuration file /etc/nginx/nginx.conf test failed

line 9 corresponds to where I made this entry.  The rest of the config contains page redirects which don't throw errors.

Any ideas what the problem is?
Each site can have one embedded location of same name.
Avatar of tf2012

ASKER

ok thanks