Q: Nginx is redirecting subdomain to main domain I have two domains,

*

*zerp.io (ssl installed)

*app.zerp.io (only http)

in zerp.io (main domain) a wordpress website is hosted and is working fine. I am trying to deploy a React app on app.zerp.io using nginx. I deleted the default file and created new file app.zerp.io at /etc/nginx/sites-available/ I also created same file at /etc/nginx/sites-enabled/ and created a symlink between them. I checked the DNS entry, app.zerp.io and www.app.zerp.io is pointing to the public Ip of the correct server where React App resides.
Here's my /etc/nginx/sites-available/app.zerp.io file
server {
        listen 80;
        index index.html index.htm index.nginx-debian.html;
        server_name www.app.zerp.io app.zerp.io;
        location / {
                   proxy_pass localhost:3000;
                   proxy_ser_header host $host;
        }


}

The problem is, whenever I try to reach http://app.zerp.io through web browser it redirects me to https://zerp.io. Here's what I did so far,

*

*I checked DNS using an online tool, its correctly pointing to the server


*I did not use any 301 redirects in the configuration file as you can see above


*when I try curl app.zerp.io from the production server (in Germany), sometimes it gives 200 with correct response and sometimes it gives 301 (moved permanently) crazy isn't it


*When I try curl app.zerp.io from my local computer it always give me 301 although I do not have any 301 in my nginx config file


*I thought, may be its a cache issue on my chrome, to my surprise no, I cleared the cache and hard reload, I even tried incognito mode with no success, it always redirect me to https://zerp.io


*When I try curl app.zerp.io from my local computer using a VPS it correctly opens the website app.zerp.io.


*I do not have any ssl certificate so there are not redirects from http to https in http://app.zerp.io
Its been two days, Its making me crazy, I am assuming it has something to do with DNS resolution. Can some please help me out
