Link to home
Start Free TrialLog in
Avatar of Jasmin shahrzad
Jasmin shahrzad

asked on

no redirect on nginx

nginx on ubuntu 16.04 not redirect permanently.
i running nginx version 1.12.2
my ssl  page not working and  curl -I  http://webserver.com says
HTTP/1.1 302 MOves Temporrarily

i have the same on other ubuntu exactly same nginx and no problem. what is wrong?
Avatar of noci
noci

curl -L    will follow redirects.   (aka curl --location )

curl -l means for FTP list only
Also useful...

curl -I -L http://webserver.com

Open in new window


Which will dump all headers + all redirects.
Avatar of Jasmin shahrzad

ASKER

doesn't matter. it's not working. i mean when we write http://web-server.com it should redirect to https://....
it doesn't.
curl -I -L http://web-server.com
say :
---------------
HTTP/1.1 302 Moved Temporarily
Server: nginx/1.12.2
Date: Tue, 10 Dec 2019 08:05:06 GMT
Content-Type: text/html
Content-Length: 161
Connection: keep-alive
Location: http://aa.com
Strict-Transport-Security: max-age=31536000

HTTP/1.1 302 Found
Server: nginx/1.12.2
Date: Tue, 10 Dec 2019 08:05:06 GMT
Connection: keep-alive
Location: http://aa.com
Strict-Transport-Security: max-age=31536000

HTTP/1.1 500 Internal Server Error
Server: nginx/1.12.2
Date: Tue, 10 Dec 2019 08:05:06 GMT
Content-Type: application/json;charset=ISO-8859-1
Connection: keep-alive
X-Artifactory-Id: 6acaec07491b1fc7:67bdf17c:16ec78faeb7:-8000
---------------
can not find  302 for redirect then take a alphabetic and redirect to aa.com
The problem is aa.com responds with  500 error.
So the redirect (-L) / 302 response works, The followup on the next server fails.

apparantly the aa.com server has a misconfiguration reaching some internal backend for url: http://aa.com/

Can you explain what you need?
i removed aa.com and restart nginx . for http://web-server.com.
i get "
This page isn’t working web-server redirected you too many times.
Try clearing your cookies.
ERR_TOO_MANY_REDIRECTS"
i move aa to tt.com and restart nginx result is the same  "this page isn't ..."
if i just rename it like alphabetic before website-com it's open this page otherwise say "this page ..."
1) what do you want to accomplish?


if there is nothing handling stuff: redirect http://web-server.com -> http://web-server.com   will get you too many redirects.
if aa.com points to the same web server and  redirect http://web-server.com -> aa.com then the server still needs to handle aa.com
( for example keep it simple and put a file index.html in the top level directory and put a text inside like: your are in aa.com now).
what i want is redirect http://web-server.com  to https://web-server.com 
right now if http://web-server redirect to http://aa.com and if i remove aa its says: "This page isn't ..."
ASKER CERTIFIED SOLUTION
Avatar of noci
noci

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
i don't understand i have had the same as your second suggestion (except for root/... and i have 301 for rewrite) and change to what you suggest now it's working  THANK YOU
sorry i was fast. it's not solved  yet.
now curl -I -L  http://web-server.com return :
-------------
"HTTP/1.1 200 OK
Server: nginx/1.12.2
Date: Wed, 11 Dec 2019 13:17:49 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Tue, 17 Oct 2017 13:16:37 GMT
Connection: keep-alive
ETag: "59e602b5-264"
Accept-Ranges: bytes"
------------
and from browser http://web-server.com return nginx default page . i removed default page from site-avi.. and site-enable.
where default page coming from? :-( .
SOLUTION
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
solved. Thanks