Say I usually make requests to my app using the local network ip address 192.168.1.26
I now have a new subdomain. How do I find the local network ip address of this new subdomain ?
With the Rails console or with a command line, either is good.
Add subdomain.example.com to your /etc/hosts file, pointing to the IP address.
example:
172.16.31.196 devwork subdomain.example.com
Then you can just type the subdomain.example.com in your url and you'll get what you want.
Related
I need to know the difference between DNS name and IP address.
Context --> Client applications interact with ALB(application load balancers) which in turn interact with EC2 instance.
Now it is told that we get a fixed hostname with "ALB", so does this mean we get a fixed IP which is all our applications can connect to ALB only via one IP address ?
Regards,
Somen Swain
I have a container called web, it contains my application and apache webserver. When I put to browser address 0.0.0.0:8090 i get my working application. But i need to change this address to mastery.local. How do I do that without using /etc/hosts file.
This can only be achieved via DNS resolution.
The simplest way would be to add this entry to the /etc/hosts.
As an alternative you could setup an dedicated DNS server on your machine which resolves this address to 0.0.0.0 and then configure your machine to use this DNS server.
I need to simulate an error on my rails application.
In my running application I have the following address: net1/redmine/projects/
When I'm going to simulate this in my machine, the command rails s start my server on localhost:3000/projects/
There is a way to start the server changing the address like for example: test1/redmine/projects? How can I do it?
If you want to change the route of your specific page you can change it in routes.rb. If you want to change the IP and PORT on which you serve your application, you can do: rails s -b $IP -p $PORT.
In what way would you need to use the net1/redmine/projects/ address?
I would instead of changing servers adress, change the the above address to your local host in your test cases.
What I mean is that in your test, u change that used address to local host via a stubbing or override if that is what you need.
This way, all your testing is done with local host as address but your live version still has original address.
I see something like this in several Rails install guides. What exactly are we doing here?
Add default subdomain to /etc/hosts, for example:
"0.0.0.0 localhost.lan group1.localhost.lan group2.localhost.lan"
You could either bind a domain/subdomain to localhost 127.0.0.1 or 0.0.0.0 to have an address which you can use in your browser to access your app.
When a service is listening on 0.0.0.0 this means the service is listening on all the configured network interfaces, when listening on 127.0.0.1 the service is only bound to the loopback interface (only available on the local machine).
So "0.0.0.0 localhost.lan group1.localhost.lan group2.localhost.lan" means "Please make the domains localhost.lan, group1.localhost.lan and group2.localhost.lan browsable and point them to all my network adapters".
It means all the domains and its aliases will point to all the IP addresses assigned to this machine.
So If you machine has 3 IP NIC and IP is assigned to each one. Then that line will point all the names to all of those 3 IPs.
If you are developing an app which requires a valid subdomain, the rails guide talk about adding that subdomain to the hosts file. so that they can route that request to your localhost(127.0.0.1)
example:
127.0.0.1 sampleapp.heroku.com
I'm brand new to RoR and have pretty much 0 experience with it. I have been handed down somebody else's project and I need to find a way to host the application, so people can just access it locally. The application is a spider script/walker script/web scraper whatever you call it. Basically it connects to a website, logs in, retrieves certain data each day and maps it with the previous data. While on the local machine, you use it, go to localhost:3000, and you get the webpage the previous person designed. I was just wondering how I could get that page to be public for the people on our local network, so they could connect to some arbitrary IP and see the same page (it updates daily)?
What I tried doing is making the folder containing the application public to the network, but in order to use it, I would have to make everybody on the network allowed to write to it and each person would have to install RoR to use it. I want to avoid that since it doesn't seem logical, nor is it what I'm trying to do.
Looking at the code, I can reverse engineer and understand what it does, but when it comes to hosting web apps locally or something of that sort, I have never done this before. Please help!
Thanks in advance!
**EDIT
-This is all being done on a Windows 7 machine.
Since you're on Windows, open up a command line and run ipconfig to find out your local IP. It will be listed under 'IP Address'.
Tell people in your LAN to access http://192.168.x.x:3000 replacing 192.168.x.x by your IP address from step 1.
EDIT: One major thing that I missed, you are windows. On windows u could use thin and put it behind a load balancer. Although i would suggest hosting it on a UNIX machine :)
Although Running it in webrick(webrick is the application server for development i.e when u run rails s) will let other users access the website NEVER do the same for a production application. If you want to run this application in production, u need more powerful application servers like passenger. I would suggest you use it with Apache or Nginx instead of stand alone passenger. Once all this is setup others can use your application by entering the IP(xx.xx.xx.xx) also u can ask your system admin to setup a local DNS so your users need not remember the IP address always.
Description:
While starting Rails Server, we can also setup some options to configure the IP address and also the port number of the site under development environment to host the website in local network. So if we want to change the IP from http://127.0.0.1:3000 to http://192.168.x.x:port (x= 0 to 255 any one number), we can set that in Rails server command! But for this, we will need to find out our current IP address at our current network which will help us to serve the website in local network.
So at first step:
We will open our terminal on our PC. For Android user, we need to open Termux app. Then simply type ifconfig to get the IP address of our device in the current network. We will get an output like this one (Here I'm using Android device for development. So output might be something different than this one on your PC terminal but the process is same):
$ ifconfig
Warning: cannot open /proc/net/dev (Permission denied). Limited output.
lo: flags=XX<UP,LOOPBACK,RUNNING> mtu XXXXX
inet 127.0.0.1 netmask 255.XXX.XXX.XXX
unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen XXXX (UNSPEC)
wlan0: flags=XXXX<UP,BROADCAST,RUNNING,MULTICAST> mtu XXXX
inet 192.168.1.103 netmask 255.XXX.XXX.XXX broadcast 192.168.1.255
unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen XXXX (UNSPEC)
X= some numbers with our device credentials which is dummied with this variable
If you are using a WiFi router then we will need the wlan0 part to get our device IP. Under wlan0 section there is a subsection of inet showing our current IP! YUP, we need that IP address 192.168.1.103! This might be different for your device and network. This is the key of this mission! Now we're going to the second important step.
So the Second Step is:
That required input command to configure the IP address.
rails s -b 192.168.1.103 -p 8080
Here:
rails s for rails server
-b 192.168.1.103 for bidding the IP address for customisation from the default IP http://127.0.0.1 which is our localhost address.
-p 8080 for port setup. This part is optional. Default port is 3000.
This is the process of changing the localhost IP (http://127.0.0.1) to local network IP which will be available for other device of the same network user.
Now our rails app is available in our local network! Other users in the same network will also be able to visit the website while the server command is running. And the link will be http://192.168.1.103:8080 if you also configure the port number. Otherwise if you have used the command rails s -b 192.168.1.103 without port configuration the link will be: http://192.168.1.103:3000
Again: 192.168.1.103 was for my case, your IP address will be different for your device. That will be needed to use for your server and link address.