Nginx returning a 400 error when trying to point a new domain at an existing subdomain - nginx

I have a domain running
http://www.exampledomain.com
and I have a subdomain that is working correctly at
http://mysub.exampledomain.com
both have web pages being served by nginx and I am able to hit both of those without a problem.
I have another domain that I want to point at that subdomain so it serves the same pages without redirecting the url.
http://www.myotherdomain.com
On that domain I setup these records
host name: www
ip address/url: mysub.exampledomain.com.
record type: CNAME (alias)
host name: #
ip address/url: mysub.exampledomain.com.
record type: CNAME (alias)
Now when I try to load http://www.myotherdomain.com I get a 400 error coming from nginx. Because it's an nginx error I'm assuming the dns is making it through but I could be wrong. Do I need to do something to let nginx or ubuntu be ok with serving requests from this domain? Modify my hosts file or something?
Edit: Now that it's been a little bit I'm no longer getting the error but It's loading the content of my first url. So using the psuedo domains above... www.myotherdomain.com is now loading the content of www.exampledomain.com instead of mysub.exampledomain.com

I was able to get this working by changing my record types from CNAMEs to URL frames. If anyone has more knowledge on the subject I would still love to know why my previous setup was causing nginx errors and this one isn't.

Related

nginx redirect remote URL to local files

Trying to do something simple (I think) but stumped on how to get there. It doesn’t help that I’m new to nginx. I’ve read through various posts and anything else I could find.
I want to configure nginx to redirect all requests to a specific URL to a folder on localhost. For instance, the following requests:
https://www.example.com/alpha/beta/gamma
https://www.example.com/alpha/beta/gamma/index.html
https://www.example.com/alpha/beta/gamma/assets/images/friend.png
https://www.example.com/alpha/beta/gamma/main.ce6329ef0ed8aa52d583.bundle.js
would serve up the following files:
/Users/flynn/Projects/new-ui/dist/index.html
/Users/flynn/Projects/new-ui/dist/index.html
/Users/flynn/Projects/new-ui/dist/assets/images/friend.png
/Users/flynn/Projects/new-ui/dist/main.ce6329ef0ed8aa52d583.bundle.js
All other requests to URLs starting with https://www.example.com would not be redirected but just passed through. Those requests would return responses as well as set cookies that should be automatically sent back.
Any help is much appreciated.

Azure Error 404 - Web app not found

I have publish my asp.net core web app on azure and assigned custom domain to my web app such as www.example.com and example.com. I have changed the CNAME, A and TXT record and added my hostname without issue. However, the non-www, example.com, sometimes work and sometimes it doesn't and i get an Error 404 - Web App not found. The www.example.com is always working and i don't have any issue. I tried on multiple device and computers, different web browsers and sometime everything is fine for the non-www rule but sometime i get that 404 Error. What could possibly be the issue?
These are the records i added:
A Record:
www, # and *
Txt Record:
www, # and *
CNAME Record:
www, *
On your DNS registrar, in addition to 'www' A record, you have to create a host A record with key '#' (meaning everything else) pointing to your azure external IP address. Thus example.com must work properly.

Route subdomain to a path in a Dokku app using Nginx

I have a few apps running in a aws instance with Dokku. I'm using virtual hostname, and together with some DNS configuration of my registered domain, I have the following for one of them: mydomain.com is a CNAME record pointing to the aws instance address, and Dokku+nginx take care of redirecting to the correct app/process.
The path for all API calls is /parse, as I'm using the open source Parse Server. The final server url is mydomain.com/parse.
What I want to achieve, ideally, is the following: api.mydomain.com gets redirected to mydomain.com/parse, api.mydomain.com/someFunction to mydomain.com/parse/someFunction and so on.
When researching to see how this may be possible, I found that this can be done easily with nginx, like explained here in this answer.
I can even change manually the nginx config file, but I'm afraid that it will be overwritten in future changes. How can this ideally be achieved with nginx on Dokku?

How to force canonical URL in Meteor hosted on Bluemix?

I deployed a Meteor app to IBM Bluemix which created an address like myapp.mybluemix.net.
Inside Bluemix panel, since we have our own custom domain, I registered it with the address myapp.com and then I created three routes: myapp.mybluemix.net, myapp.com and www.myapp.com. I also created an enviroment variable ROOT_URL = 'www.myapp.com', since we want the www. version to be used instead of the naked domain.
Inside the DNS provider panel, I put a CNAME record as www.myapp.com CNAME myapp.mybluemix.net and a A record as myapp.com A XXX.XXX.XXX.XXX (pointing to the public IP of Bluemix host).
With all these, my app was opening well, but with duplicated URLs. Then I discovered the Canonical package and republished my app with it included hoping to solve the canonical need.
Unfortunately, all requests both to myapp.com and www.myapp.com redirects to myapp.mybluemix.net!
I can't see what configuration is causing this problem. What of the described steps I went wrong?
Following steps helped me configure canonical URL :
1) Install the canonical meteor package
2) Configure two routes to your application (naked and www subdomain)
3) Set CF environment variable : cf set-env leadershipboard ROOT_URL "http://www.vamsee.ml"
4) Configure DNS server CNAME to route traffic to Bluemix application :
5) Use slightly modified meteor buildpack : https://github.com/JProgrammer/cf-meteor-buildpack
Hope it helps.
I think that very probably the error is not with the custom domain configuration (which is working fine because according to your description all the routes are resolved correctly) but with the www redirect you are doing to make the www.myapp.com the default host.
If you provide more details about you have implemented it we could help you in finding out what could be wrong

subdomain | ASP.NET | Server Error in '/' Application

I am having problems using a subdomain and ASP.NET, I guess it must be something very simple I just do not know what.
If you would like to go right to the point just jump to no. 7 below...
TVM, RConte
My hosted domain:
Hosted Service Domains: MYDOMAIN.net
Added a subdomain: (rfpesquisa)
Sub Domains
Sub Domain Remove
rfpesquisa Remove [THIS ONE]
Added a "A" record in DNS [see below]
Hosted DNS MYDOMAIN.net
$ORIGIN MYDOMAIN.net.
$TTL 86400
.....etc
rfpesquisa 86400 IN A 174.36.13.167 [THIS ONE, COPIED FROM...]
www 86400 IN A 174.36.13.167 [...THIS ONE]
TESTS MADE:
Acessed main page (not the subdomain) as usual:
(http://)www.MYDOMAIN.net/AcessaPesquisa.aspx
works fine !
Added a "kkk" so as to make for a wrong url:
(http://)www.MYDOMAINkkk.net/AcessaPesquisa.aspx
gives:
"Could not locate remote server" [as expected]
Tried a non-existing subdomain, XXXXXX
(http://)XXXXXX.MYDOMAIN.net/AcessaPesquisa.aspx
gives:
HTTP Error 404. The requested resource is not found.
[witch means to me that the server was found but the subdomain per se was not found]
Tried what I am look for dooing: (used the subdomain rfpesquisa)
(http://)rfpesquisa.MYDOMAIN.net/AcessaPesquisa.aspx
Message I got:
Server Error in '/' Application.
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /AcessaPesquisa.aspx
given that ASP.NET Message, it means to me that
--the subdomain WAS found,
the request was given to ASP.NET dll, only
it is NOT pointing to the same place as the domain, otherwise
the results for this try and no.4, the rigth one, would be the same.
file "AcessaPesquisa.aspx" is NOT in the target directory.
Please, how do I point the subdomain to the right place ?
Thank you very much,
Ricardo Conte
I guess
(1) you are using pan-domain service (one of DNS registry, redirecting requests to all sub-domains *.mydomain.net to the same server)
AND
(2) in your IIS configuration of this server, you've bound the website and the host name "www.mydomain.net" together.

Resources