How to force canonical URL in Meteor hosted on Bluemix? - meteor

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

Related

How to set up SSL with CloudFront for EC2 Instance (Wordpress)

I followed this
guide to setup WordPress on EC2, but it doesn't cover how to enable HTTPS. I've used the 'WordPress Certified by Bitnami and Automattic' AMI.
I know I can use CloudFront infront of EC2 for SSL, but I'm having trouble getting it working. I've gotten Error 502 plus several others. So I'd like to start from scratch and confirm my approach is correct.
I've registered my own domain (example.com). In Route 53, I have 'blog.example.com' as an A record pointing to my instance's EIP. I also have a CNAME record for 'www.blog.example.com' pointing to 'blog.example.com'. Both URLs can access my instance via HTTP.
In CloudFront's configuration, my 'Origin Domain Name' is:
Public DNS (ec2-XX-XX-XX-XX.ap-southeast-2.compute.amazonaws.com)
'Origin Protocol Policy' is set to HTTP
'Viewer Protocol Policy' is set to 'Redirect HTTP to HTTPS'.
For SSL Certificate, I've requested a custom cert for both:
blog.example.com
www.blog.example.com
All other CF settings have been left as default. I can access the distribution's domain name but its still HTTP.
After the Distribution is deployed, I've change the 'blog.example.com' record in Route 53 to have an alias target of CF's domain name (xxxxxxxxxxx.cloudfront.net).
What about the CNAME record (www.blog.example.com), should it be amended aswell?
Up to this stage, I can access both 'www.blog.example.com' and 'blog.example.com' but its HTTP and the EIP appears in the URL bar, not domain names.
What am I missing or have setup incorrectly?
I'm super new to AWS so many thanks in advance!
I am not sure if you are still looking for a solution but here is how I accomplished setting up SSL on my ec2 instance.
1) I issued a SSL Certificate for the URL that the ec2 was pointed at. I used AWS Certificate Manager to accomplish this.
There are two ways to verify domain authority DNS and Email. I have found DNS to be much easier, especially if you are using Route 53.
2) Next I had to list the alternate CNAME's to both of my A records (www.example.com & example.com) within Cloudfront (this tutorial was helpful). After selecting the Cloudfront distribution under the General tab click the Edit button. You will need to import your SSL certificate by selecting the radio button: Custom SSL Certificate (example.com) and then selecting the appropriate certificate that you created in Step 1.
Do keep in mind some of these steps required 15-20 minutes for the changes to propagate.
3) The final step is to point the A record within Route 53 to the Cloudfront distributions domain name.
The three AWS services you will need to utilize to accomplish this are Route 53, Cloudfront (CDN), and Certificate Manager.
Hope this helps and good luck!
Your aws configuration is looking fine. The problem is with your wordpress url, In wp-config.php you can identify the siteurl to your "domain.com" or you can set it through manually entering "domain.com" in the database. Make sure you enter https://youdomain in siteurl field.

Redirect loop in wordpress behind Azure Application Gateway

I have domain example.com pointing to Azure Application Gateway
In Application Gateway I use url based routing which routes traffic to Azure App Service (blog.azurewebsites.net), and ssl termination.
App Service this is wordpress site with WP_SITEURL and WP_HOME set to "example.com".
Now, if I go to:
https://example.com/post/ - works well
https://example.com/index.php - works well
https://example.com - redirect loop takes place
I run the WP Site on Azure App Service with Linux Environment.
Once I access my domain with HTTPS and the $_SERVER['REQUEST_SCHEME'] return 'http' instead of 'https'. It caused the problem is the WP Site loads all images, css, js.. with http
I fixed my case with these lines in wp-config.php file.
$_SERVER['HTTPS'] = 'on';
$_SERVER['REQUEST_SCHEME'] = 'https';
Can you try https://example.com/? (with the slash in the end).
Without slash, I guess it is not matching the path based rules.

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?

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

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.

Setting up domain.com as the same Meteor deployment as www.domain.com

For a Meteor JS deployment, how do your point domain.com at the same deployment as www.domain.com?
I have the A record pointing at the same IP address as www., but I'm getting the "there is no site deployed at this address message":
http://emiliotelevision.com
It appears Meteor's servers are not smart enough to make the site on www.emiliotelevision.com, which is working, also work for the equivalent with out the www..
Is there a better solution for this than pointing at another one of your own servers configured to redirect to the www. version?
Use a CNAME record for both www.emiliotelevision.com and emiliotelevision.com that points to yourserver.meteor.com
You need to set a domain redirect. emiliotelevision.com should redirect to www.emiliotelevision.com.
Now you can meteor deploy to www.emiliotelevision.com.
You may be able to set up the redirect from where you purchased the domain main.

Resources