Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have client area which is https and works fine with this added to client.mydomain.com.conf :

server {
listen 0.0.0.0:80;
listen [::]:80;

server_name client.domain.com www.client.domain.com;

rewrite        ^ https://$server_name$request_uri? permanent;
}

All client.domain.com/* pages are https.

I also have one admin area which I'am sick to make it SSL 'optimized' by changing all admin area files content.

Link of admin area is client.mydomain.com/admin

What I need is to disable https redirect only to admin area client.mydomain.com/admin, while client.mydomain.com/* will be https redirected.

I tried with this bellow code but I get error ~duplicate location "/" in /home/nginx/conf/globals/proxy.conf:38 nginx: configuration file /etc/nginx/nginx.conf test failed~

 server {
 listen 80;
 server_name example.com;
 location /admin {
   # handle admin area here;
   }
  location / {
  return 301 https://$http_host$request_uri$is_args$query_string;
 }
 }
 server {
  listen 443 ssl;
 server_name example.com;
 # ssl settings
 location /admin {
return 301 http://$http_host$request_uri$is_args$query_string;
 }
  location / {
 # handle all ssl pages here
   }
}

Here is 'client.mydomain.com.conf' file http://www.jsfiddle.net/LSyQq , it has no modifications, and here is conflicting proxy.conf http://www.jsfiddle.net/LJY3C

share|improve this question

1 Answer 1

Try this lines on the configuration is how I use to redirect my traffic

location ^~ /admin/ {
    rewrite ^ http://$http_host/$uri redirect;
  }

Let me know if it worked.

:)

share|improve this answer
    
I don't understand where to add it. Can you please edit the correct file in the correct link above ? –  Blazer Feb 13 at 16:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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