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?
Related
I came into a situation today. Please share your expertise 🙏
I have a project (my-app.com) and one of the features is to generate a status page consisting of different endpoints.
Current Workflow
User login into the system
User creates a status page for one of his sites (e.g.google) and adds different endpoints and components to be included on that page.
System generates a link for a given status page.
For Example. my-app.com/status-page/google
But the user may want to see this page in his custom domain.
For Example. status.google.com
Since this is a custom domain, we need on-demand TLS functionality. For this feature, I used Caddy and is working fine. Caddy is running on our subdomain status.myserver.com and user's custom domain status.google.com has a CNAME to our subdomain status.myserver.com
Besides on-demand TLS, I am also required to do reverse proxy as
shown below.
For Example. status.google.com ->(CNAME)-> status.myserver.com ->(REVERSE_PROXY)-> my-app.com/status-page/google
But Caddy supports only protocol, host, and port format for reverse proxy like my-app.com but my requirement is to support reverse proxy for custom page my-app.com/status-page/google. How can I achieve this? Is there a better alternative to Caddy or a workaround with Caddy?
You're right, since you can't use a path in a reverse-proxy upstream URL, you'd have to do rewrite the request to include the path first, before initiating the reverse-proxy.
Additionally, upstream addresses cannot contain paths or query strings, as that would imply simultaneous rewriting the request while proxying, which behavior is not defined or supported. You may use the rewrite directive should you need this.
So you should be able to use an internal caddy rewrite to add the /status-page/google path to every request. Then you can simply use my-app.com as your Caddy reverse-proxy upstream. This could look like this:
https:// {
rewrite * /status-page/google{path}?{query}
reverse_proxy http://my-app.com
}
You can find out more about all possible Caddy reverse_proxy upstream addresses you can use here: https://caddyserver.com/docs/caddyfile/directives/reverse_proxy#upstream-addresses
However, since you probably can't hard-code the name of the status page (/status-page/google) in your Caddyfile, you could set up a script (e.g. at /status-page) which takes a look at the requested URL, looks up the domain (e.g. status.google.com) in your database, and automatically outputs the correct status-page.
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.
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
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.
I'm trying to stand up an EC2 instance with elastic search using nginx as an front end node access point. I used this tutorial to set it up.
http://nginx.com/resources/admin-guide/setting-nginx-plus-environment-amazon-ec2/
According to it I should be able to "check it by pointing your web browser to the public DNS name of your newborn EC2 instance."
But when I go to the ec2 domain in a browser I get json of the cluster status.
I have an index.html that I've place in /var/www/index.html but I am unable to access it from a browser.
I am not sure what I did wrong but I used this example instead and it's all working ok.
http://www.comtechies.com/2014/03/How-to-install-and-configure-nginx-on-amazon-ec2.html