Hosting two RoR applications on same server - ruby-on-rails-4

I have a RoR application running on a server(VM) alone. It doesn't have any domain name and we are using dedicated IP address to access the application(e.g. 192.168.1.1/app). The folder structure of this app on the server rests like /var/www/app.
My question is that can I use the same server for hosting another RoR app2 as /var/www/app2 and access it in same way 192.168.1.1/app2 ?
We have thin server running for the application and Apache for handling proxy requests.
Please guide.
Thanks in advance.

You have to start the server and bind it to a different port:
thin start -p 81
then you can go to it via 192.168.1.1:81

Related

Can a remote server send response to a local client on a custom port?

For network gurus out there, I'll like to ask some questions regarding some unique setup where the server will be sending a request to a client on localhost on a certain port.
I have a cloudy understanding of some network fundamentals that I hope you'll be able to help me out.
Kindly check the image below:
Basically, there's a static website hosted in AWS s3 and at some point this website will send a request to https://localhost:8001.
I was expecting that it will connect to the nginx container listening on port 8001 in my local machine, but it results in 504 gateway error.
My questions are:
Is it possible for a remote server to directly send data to a client at a particular port by addressing it as localhost?
How is it possible for the static website to communicate to my local docker container?
Thanks in advance.
In the setup you show, in the context of a Web site, localhost isn't in your picture at all. It's the desktop machine running the end user's Web browser.
More generally, you show several boxes in your diagram – "local machine", "Docker VM", "individual container", "server in Amazon's data center" – and within each of these boxes, if they make an outbound request to localhost, it reaches back to itself.
You have two basic options here:
(1) Set up a separate (Route 53) DNS name for your back-end service, and use that https://backend.example.com/... host name in your front-end application.
(2) Set up an HTTP reverse proxy that forwards /, /assets, ... to S3, and /api to the back-end service. In your front-end application use only the HTTP path with no host name at all.
The second option is more work to set up, but once you've set it up, it's much easier to develop code for. Webpack has a similar "proxy the backend" option for day-to-day development. This setup means the front-end application itself doesn't care where it's running, and you don't need to rebuild the application if the URL changes (or an individual developer needs to run it on their local system).

Hosting Back end Application with API on EC2 instance

I'm quite new to AWS and I have been starting to work with EC2 instances. I have a web application that has a frontend and backend separately. So first I hosted the backend application on EC2 instance and it is a Symfony framework based REST API Application. So I have installed all dependencies and now the application is running. But to check the application I ran some API calls to the application using postman and seems application is not working as intended. I get following response from Postman. I have also provided security group configurations properly.
When I start sysmfony app it says [OK] Server listening on http://127.0.0.1:8000.
Can't figure out why this is happening. Can someone help me here?
You are running your application trough CLI (Symfony web server bundle) , by default this will bind to 127.0.0.1 which can't be accessed from outside. To fix this, you must bind to your server's public IP/hostname and port:
php bin/console server:start 192.168.1.1:8000 # replace with your ip
You can also bind to all your IP addresses using 0.0.0.0
But keep in mind, you should not use built in server for production, it's slow and less secure. Use a real web server instead, like Apache or Nginx.

Rails - How can I remove the :3000 from the URL in rails thin server?

I have binded my rails thin server to a local IP. which I have given the domain name as project1. But when I am changing the hostname to project1 sometimes it goes to project1:3000. How can I remove the :3000 from the URL?
Web standards are:
http is port 80.
https is port 443.
When you go to http://stackoverflow.com, it is the same as http://stackoverflow.com:80 or https://www.google.com is the same as https://www.google.com:443
So, the :3000 at the end of the url is the port where your development server is pointing, this is normal behavior for web development. All modern frameworks will serve up the development site on a different port, 3000 being the most common. This is done for a lot of reasons, two good ones are.
Don't need to change any permission to run on port 3000, like you do if you want to run on 80, and you don't need to us an ssl certificate if you run on 443.
You can tell when you are in development.
You are trying to do something you shouldn't. If you haven't used the correct helper methods to build your links in rails you could run into some issue.
Now that you know why you shouldn't do it. You can just change the port in the rails server command like this rails server -b THEIPYOUWANTTOUSE -p 80. You will have to have the correct permissions.
First of all.You need proxy server, because rails have their app server lika thin, puma, rack and you need server that will accept requests to your IP (nginx, apache) and give them to rails server. There is a lot of guides how to deploy rails app in production mode. Try this guide or this one . This will help you run your application in production mode.

Specify the port precisely for a webservice in Web.config

I want to precisely set the port for a .NET 3.5 web service using the client services api
I have been trying to get this to work using
http://msdn.microsoft.com/en-us/library/bb546195.aspx to no avail I have my domain mydomain .com / Appservices where is Appservices is an app root.
I can login to my web site using the login page but the login when the app is running does not autheticate. But 2 local webservers start running the main website and the webservice that is a directory off of root the aforementioned AppServices.
What are the troubleshooting techniques here?
Is the port you want to use, already in use? (For example, 110 - POP3).
Is the port accessible through the firewall? [Start->Control Panel->Windows Firewall : Exceptions]
Have you tried setting the port number in IIS? [In properties-> configuration]

Web Service Port No Question

I am working on a web service project using gsoap. I am new to web services and have some basic questions.
What should be the port no. of my web service? Currently this web service is a stand alone service listening to a hard-coded port no. of 22050. Client connects to this port and everything works fine. Is this approach OK? What are the pros/cons of this approach?
Or Should my web service be a plug-in of the apache web server? In that case how does it work? Apache httpd listens on port 80, so client sends request to this port. Then how does the request get routed to my web service?
I didn't find any proper online resources on these. Any pointers would be great.
You will have to configure apache such that it knows it will be your web service. In this case you will probably give it a location. So you can configure a directive that will make sure your service is called by apache.
I.e. you will use urls that identify your service (http://.
You will then use a location directive in which you make the proper configurations. You can find more information at http://httpd.apache.org/docs/2.0/sections.html
Hope this helps.