Welcome! Log In Create A New Profile

Advanced

redirect http to https, but exclude API

Posted by awinad 
redirect http to https, but exclude API
June 12, 2017 05:47PM
we switched a site from http to https, but for compatibility reasons we need some API to still be reachable by http.

our current redirect is:

server {
listen 80;
server_name www.mysite.com;

location ~ /.well-known {
root /var/www/html;
allow all;
}

return 301 https://$server_name$request_uri;
}

what do I need to change/add, to make sure POST requests to http://www.mysite.com/api/reportNew are not forwarded to https?
I tried some variants with location and root, but somehow never succeeded.
Re: redirect http to https, but exclude API
June 13, 2017 04:13PM
http {
map $request_uri $requri {
default 1;
/well-known 0;
}
……………………
server {
listen 80;
server_name www.mydomain.eu;
root '/webroot/www.mydomain.eu’;
if ($requri) { return 301 https://www.mydomain.eu$request_uri; }
location / {
try_files $uri $uri/ =404;
index index.html index.htm;
}
}

---
nginx for Windows http://nginx-win.ecsds.eu/
Re: redirect http to https, but exclude API
June 13, 2017 06:00PM
Thanks, but I can't follow :(

I can't see any specific info about /api/*
Some explanations would be very helpful :)
Re: redirect http to https, but exclude API
June 14, 2017 02:30AM
Change the '/well-known 0; ' line to an url (portion) which should not be redirected.

---
nginx for Windows http://nginx-win.ecsds.eu/
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 66
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready