Wordpress and Rails on same domain - ruby-on-rails

I have an Amazon AWS and I want to install both Wordpress and Rails on this same server using Apache. I know that we can do this by configuring Apache virtual host. The problem is with the domain. Currently, we are using example.com for the Wordpress website, this website contains other pages such as blog, help, faq, etc. For the rails app, I want to use the app.example.com as the root path. And when an user signs up, I also want to give him a unique subdomain such as user1.example.com, user2.example.com, etc
How can I achieve such things? I am thinking about using some rewrites to redirect .example.com to Rails app but I don't really know how.
Thanks in advance

The way the internet works is that you address specific machine by its address - the domain is simply a mechanism to make that address prettier - and by the service port
Now, lets say that you are addressing http://example.com
What do you need the http for? this is the protocol you are using and each protocol had a predefined well known port number
You can address a different port by stating it - example.com:3000 for example
Now, a port is like the access point to some web application, but no two applications on same machine can make use of the same port
This is the reason that you can not run both WordPress and Rails server on the same machine and port
So change the port number, right? Not exactly - Because people will not know on which port you put it and will not be able to access it - However, I'm not sure, but in your Name Service Provider (GoDaddy, Networks Solution etc.) in the CNAME definition you might be able to point http://example.com to [your machine name]:[your port] - I'm not sure , you should check it out
Your options:
Use same machine - Leave the WordPress as is, put the Rails on HTTPS (port 8080) - Which is the secured protocol and it is also reasonable if the user need to put in some details that you want to be safe - Then your address will be https://app.example.com and you should update it also in your Service Name Provider settings and also set up a certificate and all read more about it before you start doing that
Use two machines - If you use a micro machine for the rails application it costs you nothing and put your DB also on AWS so you will have access to it from both machines
Hope I was helpfull

Related

How to bring two Cloud Run Apps under one domain to avoid CORS

I have two apps I wanted to have "fully managed" by Cloud Run. One is a pure Vue.js SPA and the other is the belonging backend server for it that is connected to a MySQL and also fetches some other API endpoints.
Now I have deployed both apps but am totally unaware on how I can give the frontend app access to the backend app. They should be both running on the same domain to avoid the frontend from.
Current URL of the frontend app: https://myapp-xl23p3zuiq-ew.a.run.app
So I'd love to have the server accessible by: https://myapp-xl23p3zuiq-ew.a.run.app/api
Is this somewhat possible to achieve with Cloud Run?
I was having the same issue. The general idea that one usually has is to use path mapping and map / to your client and /server to your backend. After googling for a while I found this:
https://cloud.google.com/run/docs/mapping-custom-domains
Base path mapping: not supported
The term base path refers to the URL
path name that is after the domain name. For example, users is the
base path of example.com/users. Cloud Run only allows you to map a
domain to /, not to a specific base path. So any path routing has to
be handled by using a router inside the service's container or by
using Firebase Hosting.
Option1:
I ended up creating an "all in one" docker image with an nginx as reverse proxy and the client (some static files) and server (in my case a python application powered by uwsgi).
If you are looking for inspiration, you can check out the public repository here: https://gitlab.com/psono/psono-combo
Opttion2:
An alternative would be to host your client on client.example.com, your server on server.example.com and then create a third docker run instance with a reverse proxy under example.com.
All requestes would be "proxied" to the client and server. Your users will only interact with example.com so CORS won't be an issue.
Option3:
Configure CORS, so people accessing example.com can also connect to server.example.com
Currently this is not possible in Cloud Run, as already said on the comments to your question.
You could check if there are any Feature Request for this functionality on Buganizer (Google Issue Tracker), currently there seems to be none, and if that is indeed the case, you can create a new Feature Request by changing the request type from Bug to Feature Request and as Google develops it on their road map, you will be informed.
Hope this helped you.

How to redirect traffic for my url to my own linux server?

I "own" a URL www.example.com which is currently hosted by One.com. I recently built my own server running a LAMP stack and it serves pages to the internet from /html as it should, but is only accessible via numeric IP address. In the past I've re-assigned the name servers for URL's but only using a hosting company's "dashboard" or GUI. I've read about changing the DNS settings in Ubuntu (my server is running 18.04) and also I've researched what I can into Google's public DNS and DynDNS services.
So I have two sets of questions. First, is it possible to "connect" or "bind" a URL to the static IP address of my own server without using a DNS service? Can it be done through any kind of public registry and if not, what are the least expensive but still reliable options?
Second, is basically "Why bother?" I do understand the value of a human-readable address but also, the address bar isn't realistically used anymore. Most of the security value of having human readable addresses depends on users actually looking at the address bar so that's becoming a moot argument. People only navigate the web now through links and Google searches, and the address bar is essentially a developer tool. It seems like I can pretty much replace the need for DNS with masked links and meta titles?
You need to set your domain's "A Record" in DNS to point to your server's IP address. While not neccessary, you can configure Apache to respond to the correct domain with virtualhosts [https://httpd.apache.org/docs/2.4/vhosts/name-based.html ], but you will need the DNS configured correctly first.
It is not possible to bind a domain to an IP address without DNS - DNS or Domain Name System is THE authoritative system for doing so. It's how the world wide web functions.
Here is some additional reading on what DNS does and why it's important: https://www.cloudflare.com/learning/dns/what-is-dns/

How to publish and host a MVC4 application in your domain?

I have a webdomain www.MyDomain.com and a MVC4 web application MyMVCWebApp.
First I publish the application to a local destination.
For instance: C:\TempLocation
And then I host it to my domain with a FTP-tool (FileZilla??)
The files will be hosted but I can't find the webpage.
Which url do I have to write?
http://www.MyDomain.com/MyMVCWebApp/Home/Index.chtml or something?!
Do I have change the settings in my web.config?
What do I have to do?
You can't host an application on a domain.
An application is hosted on a web server. A domain name is only a way to translate an easy to remember address like "www.google.com" to the web server ip address which looks like 173.194.66.104
It is possible to purchase a domain without a web server.
So before going further:
Check if you actually bought a domain only, or a domain with a server
Your domain should redirect to your server ip address, you can see if he is correctly configured by opening a command prompt and doing
C:\> ping www.yourdomain.com
If this is not the case you will need to update the A record of your domain, and wait for the update to be replicated on DNS server worldwird.
If you have a managed server, you should check your hosting provider website. They usually provide in depth documentation, and they all have a different way to do things. Most of the time indeed you will be able to upload your files using a FTP software such as Filezilla.
However, in order to host a MVC 4 application you need a server with
the IIS web server, which means that you need a Windows server. So if
you have a Linux server, you should contact your hosting provider
support and tell them you made a mistake during your order. (It is
possible to host a MVC 4 application on Linux, but I don't think it
is often provided on managed servers)
If you have a dedicated server you are on your own.
The URL you will have to write to access your application will depends on what you have configured in the RegisterRoutes method of the RouteConfigs.cs file.
I recommend you to watch the last video on this page to have a better overview of the possibilities.

smtp4dev - access from remote computer

Is it possible to access smtp4dev from a remote computer. I am using smtp4dev locally for development so that I can view emails as my ASP.NET MVC 3 application sends them out. It would nice to be able to do the same one a testing server with the ability for me or a colleage to view messages being generated on that remote testing server.
If smtp4dev can't do it are there any other tools that can? I know it is possible to output files to a share via ASP.NET configuration, but I find smtp4dev to be a much more user friendly experience...
It sounds like you need to access you local smtp4dev service from a hosted instance of your project. You have several options:
Personally, I use a gmail account for doing this - you're limited to 100 emails per day.
Port forward your local smtp4dev service - find the IP address of the computer it's runnning on, the port the service operates on (SMTP port), go to your router and add the port forwarding rule / Virtual Server. It's possible that smtp4dev only bind to the loopback interface, in which case port forwarding won't work. You should also make sure the firewall exception is added for the port or program.
Your hosting might already have an SMTP server you can use
You could use a public SMTP server - mail.{someisp}.com
In any case, if you're a bit more specific, we will be able to help you further.

How to host a Rails application as an API that is only accessible locally?

I am starting to create a RESTful API that is built on Ruby on Rails. I would like my other applications (which are hosted on the same server) to be able to use this API. I had the idea that if the API is only available locally, I won't have to deal with the authentication logic since it won't be publicly accessible. I have never done this sort of thing before, so I don't even know if what I am asking for is possible (or if this is even a good idea).
How can I host this application so that my REST API is only locally accessible?
You can do one of the following:
Set the webserver to listen on loopback only
If you need to give access to the local network then configure your firewall to forward ports accordingly
Set the webserver to listen only on the private network interface (not public)

Resources