Can we use Apache Sling for Production serving a website directly without any other web server? - sling

We are developing a website using Apache Sling API. The site works good on localhost:8080. Can we change have our website served from directly from Sling instead of any middle web servers (like Apache)?
Can we change the host name in Apache Felix Http Based Http Service from 0.0.0.0 to www.domain.com ?
Is this possible?
www.domain.com --> Apache Sling --> Linux VM

Yes, of course you can. But as the commenters have pointed out, it's probably not a secure solution. We do not have our our production-readiness checklist, but you might want to study the AEM Security checklist, as many items apply to it.
Pay special attention to items such as:
Change Default Passwords For the AEM and OSGi Console Admin Accounts
Protect against Cross-Site Request Forgery
Unfortunately many of the items present under the dispatcher checklist are not applicable, since the dispatcher is only available to AEM customers. However, at a minimum I would suggest that you block access to
the web console
composum (if deployed)
the DavEx Servlet

Related

Does Puma have something like Apache's "Location" tag?

I'm using Puma (version 3.11.0) as the web server for a Rails application (Rails version 5.1.4). I need the whole application to be SSL encrypted, but I need one particular route to also have the SSL "verify_mode" set to peer. In Apache, I would normally use a "Location" or "LocationMatch" block to configure the SSL options differently from the rest of the site.
How can I do the same thing with Puma?
I totally agree with #user3309314.
Exposing Puma to the internet directly (or exposing any application server, for that matter), isn't a great idea.
Web servers (unlike application servers) are designed to be in the front, protecting application servers from the cruel world...
...and along the way, they should be the ones to handle SSL/TLS (along with DoS attacks and other annoying concerns).
So use nginx or apache to forward requests to your Ruby application(s) and if you need a special TLS/SSL rule for a specific path, do that with nginx or apache.
Puma doesn't (and IMHO shouldn't) support the feature you're asking about.
EDIT (some of the information given in the comments + explanations)
It's best to think of application servers as a "bridge" between the host machine's routing layer (nginx/apache) and the applications.
It's the host routing layer (nginx/apache) that filters and routes certain host names and paths to certain applications (or the same application with different headers / variables / requirements).
The application server's job is to simply "bridge" between the host routing layer and the actual application, translating between the different data formats (HTTP data to Ruby objects and back).
In order to support the feature you're asking about, the application server should perform the same functions as the host routing layer (routing the correct host name / path to the correct application with the correct changes)
This would violate any "separation of concerns" as well as add redundancy to the system, inflicting a performance penalty (not to mention the larger code base that duplicates the same task in different modules).
This is the reason why, IMHO, these features should not get coded into Ruby application servers.
It's unlikely that Puma supports this.
But you can configure Nginx or Apache as a reverse proxy, so requests get forwarded to the Puma application server, and you can configure SSL options as you need.

is it possible to have multiple project of rails on same port?

I want to add a new project beside of my current rails app without starting a new server for that.
I think it is impossible to have two rails app on one port but my boss want it.
Is it possible at all?
Yes it's possible if you configure a web server (nginx, etc) as a reverse proxy to listen on the port you want, and have it forward traffic to the correct app based on subdomain.
Yes and no. You can't run two web servers, e.g. Puma, on the same port. That won't work. But you can run one web server to serve two Rails apps. Incoming requests are routed based on either their subdomain (app1.example.com) or their path (example.com/app1).
A common setup is to use Apache/nginx as the web server in combination with Passenger as the application server. This question ask a similar question and points to Passenger's documentation on how to serve apps from subdomains: How to deploy multiple rails app on a single IP (Apache + Passenger)?
The configuration depends heavily on your setup, so I can't give you a more detailed answer. But searching for "multiple apps" and the combination of your web and application server should yield enough results and tutorials for you to solve your problem.

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.

How to setup wordpress site and rails multiaccount site

I have TLD (www.example.com) and want to deploy rails 3 app (ex. app.example.com) what will have multiple accounts, each account with one subdomiain (test.example.com, support.example.com, ...).
I created tld with subdomain, changed DNS records, and everything is working. But, since there will be CNAME redirection from some other sites to specific subdomains and my default site is TLD (www.example.com) all CNAME redirects are going to main site instead of analogus subdomain!
Is there better way to integrate Rails and Wordpress? How to solve that? I'm searching for solution last two days.
Similar question: https://stackoverflow.com/questions/10405859/how-to-config-apache-passenger-for-wordpress-and-rails
If your ruby is in passenger mode, and your apache servicing all http queries you should be able to use the apache virtual server setup to redirect the queries for your rails apps accordingly, while leaving your Wordpress on the default web server.
I haven't done it with rails, but for Diaspora, (which is a ruby app) I have that running side by side with a Wordpress network with numerous subdomains off the TLD. The key might be that your TLD should be example.com, not www.example.com. (setup whichever you prefer to have wordoress on to redirect to the other)
Post some more details on your apache (or other web server environment) setup to achieve some better assistance if this doesn't help.
Yours for the cause of open source!

Configuring multiple applications in RoR

I would like to have multiple RoR applications that can communicate with each other (databases, method calls, ...).
Example of what I would like:
a main application running on a URL http:// www.< application_name >.com
a sub-application 1 running on a URL http:// www.< application1_name >.< application_name >.com
a sub-application 2 running on a URL http:// www.< application2_name >.< application_name >.com
each with own databases.
How can I configure my applications? Where can I find a tutorial for my needs?
No Problem. In your case you will have 3 distinct Rails applications. You will setup your Webserver to send requests based on host accessed to one of the three applications. This is standard web server configuration. You'll need to read Apache or Nginx configuration on how to route request to the right rails application.
EDIT:
http://articles.slicehost.com/2009/3/11/ubuntu-intrepid-nginx-rails-and-mongrels
Not sure what you are going to use as your Web Server (Apache or Nginx or something else) or what you are going use as your application container (mongrel/passenger/thin etc) but this article above should help.
You might take a look at the eco_apps gem - https://github.com/idapted/eco_apps. I heard the developers give a talk about it at Rails Conf '10. Fascinating stuff, though I haven't had a chance to use it yet.

Resources