routing subfolder on S3 to wordpress blog on EC2 microsoft server - amazon-web-services

I'm using Amazon S3 to host static files for my website. Now I wanted to add Wordpress blog, which would be hosted in /blog subfolder. I followed an article which explains the easiest way to install Wordpress on EC2 on Microsoft Windows server here:
http://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/EC2Win_CreateWordPressBlog.html
I'm wondering how can I set /blog/* subfolder of my static site on S3 to rewrite all urls to a blog hosted on EC2.
How is that possible?
Thanks for help

As far as I know that's not possible. S3 supports redirects, but it won't act as a proxy for your dynamic content as there's no concept of URL "rewriting" (which can only really happen at the webserver level unless you're redirecting to a completely different domain). You have a few alternatives though.
Host your wordpress blog on a subdomain. blog.yourdomain.com keeps your blog and you just link to it from your static site.
Find a way to generate static files from your wordpress blog and put those files in the blog "subfolder". There are wp plugins that will do this I believe.
Just thought of a new one. Set up cloudfront in front of your website and use behaviors to forward requests to your blog server.
There is a final option where you make your default 404 page into a little js application that acts as a router for fetching pages from your wordpress backend but hahahahaha don't do that.

Related

Will I be able to use a wordpress site domain as a django website on a VPS?

I deleted all the files and folders associated with the Wordpress site I intend to write from scratch using standard HTML, JavaScript, CSS and with Django framework. My question is if I can use this domain with this newly created site in a VPS.
At first I had erased the files and folders and recreated it with the Django app right onto the Wordpress structure, and that does not seem to be working. I am most likely doing something wrong anyways, but I am after the right way of accomplishing this.
Domain names are separate from web servers (such as your VPS), CMS (e.g. WordPress) or a framework (e.g. Django). So there is no problem using that same domain name for your new website with Django.
However, you'll need to reconfigure your VPS to run Django. Better if you reinstall your VPS with Django. Follow the guide provided by your VPS to install Django properly. This includes configuring the web server (e.g. Apache or Nginx), setting up a database, and properly linking your domain to the new server.

How does url http://app.mywebsite.com works?

I am currently developping a SASS web application, and I want to deploy my react app under an url like "https://app.my-website.example". So I tried to buy the domain name "app.my-website.example", but apparently, domain name cannot contain "." character.
How can I deploy it under an url like "https://app.my-website.example" ?
I have seen quantity of modern websites with url containing "app." at the beginning.
For example, website about crypto usually have a traditional static website describing the project, deployed on an url like "https://website.example". And then, their actual application, which does stuff, is deployed on an url like "https://app.website.example".
This is also true for most web application out there.
I use AWS Amazon cloud if it helps you answer me.
Btw, I have already bought the domain name like "my-website.example" and have deployed my static website on it.
Here is the solution.
So the answer to my question is that I need to create a sub domain inside my main domain.
I don't need to buy anything else to create the subdomain, since I already own the domain. It is the main advantage compared to buying "app-mywebsite.com". Plus, it will be easier for google to reference my app.
On amazon, you need to go to the "route 53" service to create the subdomain and then redirect it to you application. The doc to do that is here :
https://aws.amazon.com/premiumsupport/knowledge-center/create-subdomain-route-53

Suggestions for hosting SPA on AWS

I have an application that has an Angular Frontend and a Django Backend. I've already set up my django application to run on Elastic beanstalk, however, I am unsure what I should do to serve static files. I'd rather not handle this within the django application.
I have tried using nginx reverse proxy with elastic beanstalk to properly serve files, however I'm unable to serve them on "/", only extensions like "/index" or "/dashboard", and the js files the index.html needs aren't found (404 error).
I thought about rewriting the entire nginx configuration but I'm unsure where to start. Any ideas would be very helpful!!
You can host your Angular frontend on S3 (with website hosting enabled). To make it more performant and cheap, add CloudFront in front of it. Different paths (APIs) of your application can be routed to backend via CloudFront "Behaviours" feature. You can set No-Caching for those dynamic paths.
Reference:
https://medium.com/#peatiscoding/here-is-how-easy-it-is-to-deploy-an-angular-spa-single-page-app-as-a-static-website-using-s3-and-6aa446db38ef

Is it possible to have a Heroku app I built be on the same domain as my Wordpress website?

I have a website hosted on Wordpress at domain [my domain name].com. I built an app using Django that is currently deployed on Heroku at [my domain name].herokuapp.com. The apps do not have conflicting routes. For example, the '/' route does not exist on the app I built myself. Is it possible to configure my DNS settings on Heroku such that I can use my custom domain name where a Wordpress website already lives?
I think you are asking if both of your applications can live at the same domain.
The answer is yes....sort of.
Subdomains
Your two sites would need to be on separate subdomains. For example your heroku app might have a CNAME record pointing to it like this
djangoapp.YOURDOMAIN.com. CNAME [my domain name].herokuapp.com.
I realize this might be confusing, but your django app would live at a prefix/subdomain.
Then the CNAME for your wordpress site might look like:
www.YOURDOMAIN.com. CNAME wordpress.com/YOURBLOG
No. Not in the same domain.
Treas gave you a compromise but you understand that siteA.mydomain.com and siteB.mydomain.com are two different domains.
You CAN NOT have the following situation:
mydomain.com/ <- This goes to the wordpress site
mydomain.com/a <- This one goes to the heroku site
mydomain.com/a/b <- But this one goes to the wordpress site
mydomain.com/c <- and this one goes to the wordpress again.
You have a DNS configuration issue. It is not related to Heroku nor Wordpress. DNS can not be configured with routes. They can with sub-domains like trejas has described.

Setting up a CDN with Wagtail CMS

I am looking into possibly setting up a CDN to use with my Wagtail sites. I am thinking that this will be a more efficient way to manage media uploads during stage/production pushes, since right now the media folder has to be manually copied from server to server on deploy. If all of the images were being accessed from a CDN then this wouldn't be an issue.
This would be my first time using a CDN so I'm looking for advice. There is lots of info on using a CDN with WordPress, but not a lot of documentation on setting one up with Wagtail/Django. I have the following questions about it:
Does anyone have any suggestions on the best way to implement the CDN with Wagtail?
How does it handle the uploads that the user submits through the CMS? Most of the images will be uploaded as part of the static files, but how does it work when the user uploads a photo as part of a post?
Which CDN companies have you had the best/worst experiences with? The sites I am planning to use this for are professional/business, but not e-commerce.
Also, if there is a more efficient way to handle the transfer of media uploads from one environment to another than using a CDN, I'd love to hear your suggestions for that too. As of right now I've had to copy the media folder over after doing the deploy, and I will have to do this every time I make a change to the site.
Thanks in advance for your assistance.
The following resources can be helpful for your required setup in Wagtail (later on today I can provide you some more details):
Frontend cache invalidator for pages (so not only for static and media files)
Link: http://docs.wagtail.io/en/latest/reference/contrib/frontendcache.html#frontendcache-aws-cloudfront
Storing media files in Amazon Web Services S3 buckets
This should be a better solution instead of copying media files from server to server. In this case Amazon Web Services CloudFront (CDN) would be a perfect choice.
Link: https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#amazon-s3
More info CloudFront: https://aws.amazon.com/cloudfront/
Static file cache invalidation with Django Whitenoise
Can be relevant to clear the cache for a new deployment (the static files will have a unique filename so CDN will have a new file cache from its origin after the deployment)
Link: http://whitenoise.evans.io/en/stable/django.html
CloudFront from AWS will have my personal choice for CDN. Besides the awesome resources/services AWS has to offer, CloudFront is simple to setup and has one of the best CDN's out there.
Finally a CDN for serving static- and media files has nothing to do with Wagtail specifically. There are some (see list above) nice apps available for Django itself, but you are free to choose another CDN solution (like Cloudflare).
So setting up a AWS S3 Bucket for each environment (tst/acc/stg/prd) and use it for uploading you media files (so the files aren't on the server anymore) and setup a CloudFront distribution for these buckets would be a proper solution for your problem.
Best regards,
Rob Moorman