0

I have forwarded godaddy subdomains backend.example.com and app.example.com to the same public IP XXX.XXX.XXX.XXX of Google Compute Engine. I have nginx webserver configured and my springboot backend is serving on port 8090. Currently using the following configuration-

server {
listen 80;
gzip on;
server_name backend.example.com;
location / {
  root html/example;
  index index.html;
}
location /private {
  proxy_pass https://127.0.0.1:8090;
}
location ~* \.(gif|jpg|jpeg|png|js|css)$ { }
}

My web application is working fine. But RESTful api calls only working when the url is http://XXX.XXX.XXX.XXX/api/view. When http://backend.example.com/api/view is used as url , getting back following html response

 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">
 <html>

 <head>
 <title>Backend</title>
 <META name="description" content="Backend">
 </head>
 <frameset rows="100%,*" border="0">
 <frame src="http://XXX.XXX.XXX.XXX" frameborder="0" />
 <frame frameborder="0" noresize />
 </frameset>

 <!-- pageok -->
 <!-- 12 -->
 <!-- -->
 </html>

I want JSON response to be served in backend.example.com/api/view like the way its happening for XXX.XXX.XXX.XXX/api/view. I have tried many different configuration setting in nginx config file but nothing worked. Need some suggestions how to fix this.

  • Looks like Godaddy's domain "forward" doesn't actually forward. It just loads the new location in an iframe. This won't work for an API. Use a CNAME record instead. – jordanm Jul 10 '17 at 13:18
  • but the problem is that CNAME record can't be forwarded to an IP.. have to forward it to @ or some subdomain – Mrinmoy Das Jul 11 '17 at 04:18

1 Answers1

0

So after trying for couple of days, I stumbled upon a solution to the situation.

Forward the subdomains without masking to the IP address and create a DNS zone in Google Cloud DNS. Enter A name records in Cloud DNS for the subdomains. Copy the custom nameservers provided and paste in your domain hosting sites nameservers records. This much would work like charm.