Sponsor:

Server and Web Integrator
Link:
Kloxo-MR logo
6.5.0 or 7.0.0
Click for "How to install"
Donation/Sponsorship:
Kloxo-MR is open-source.
Donate and or Sponsorship always welcome.
Click to:
Click Here
Please login or register. 2024-05-08, 17:14:14

Author Topic: nginx redirect to https all but only /admin  (Read 2555 times)

0 Members and 1 Guest are viewing this topic.

Offline crossing

  • Senior Member
  • *
  • Posts: 336
  • Karma: +0/-0
    • View Profile
nginx redirect to https all but only /admin
« on: 2014-02-15, 20:39:51 »
Hello,

I need to redirect all website to https but not mysite.com/admin/  .  I tried all solution but I get conflicts with  kloxo-mr nginx files.


Normally I must modify only nginx mydomain.com.conf file from here /nginx/conf/domains but it gives me error "duplicate location "/" in /home/nginx/conf/globals/proxy.conf:38" .


This is what I try use on mydomain.com.conf  :


Code: [Select]
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
  }
}
Kloxo-MR -> Great Panel ->  Great person behind it ->  Mustafa

Offline crossing

  • Senior Member
  • *
  • Posts: 336
  • Karma: +0/-0
    • View Profile
Re: nginx redirect to https all but only /admin
« Reply #1 on: 2014-03-01, 11:55:49 »
Anyone can help me ?
Kloxo-MR -> Great Panel ->  Great person behind it ->  Mustafa

Offline MRatWork

  • Administrator
  • The Elite
  • *****
  • Posts: 15,807
  • Karma: +119/-11
  • Gender: Male
    • View Profile
    • MRatWork Forum
Re: nginx redirect to https all but only /admin
« Reply #2 on: 2014-03-01, 12:02:59 »
Hi,

Look like you're using nginx-proxy (because include proxy.conf). For this issue, better use httpd rule for redirect to https (using .htaccess).
..:: MRatWork (Mustafa Ramadhan Projects) ::..
-- Server/Web-integrator - Web Hosting (Kloxo-MR READY!) --

Offline crossing

  • Senior Member
  • *
  • Posts: 336
  • Karma: +0/-0
    • View Profile
Re: nginx redirect to https all but only /admin
« Reply #3 on: 2014-03-09, 11:58:37 »
I tried that but I get redirect loop when load the site. I remove nginx redirect and added this on .htacces :

Code: [Select]
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
Kloxo-MR -> Great Panel ->  Great person behind it ->  Mustafa

 


Top 4 Global Search Engines:    Google    Bing    Baidu    Yahoo

Page created in 0.07 seconds with 19 queries.

web stats analysis