I am currently running a rails application on my local machine as the backend api for a hobby web application (have too many sql rows and dont want to pay for it).
I already figured out how to forward my port and access the api through http://[myexternalipaddress]:8080/api/etc.... from the external internet.
This is working fine, but i want to be able to serve this end point through https instead so my users dont get security warnings. I did some research, but I am confused what I need to do next. Is the https serving done via my rails configuration, or some other method?
here is the command I use to start my rails server:
rails s --binding=0.0.0.0 -p 8080
You can use ngrok and expose your local server
on mac you can install it with brew
$ brew cask install ngrok
$ ngrok http 3000
this will give you url like https://xxyyzz.ngrok.io to access it publicly
Related
My rails app is spin up using puma-dev on Ubuntu.
I'm using puma-dev command to start my app (in foreground) and then access the rails app using
https://app.test:9283.
As the puma-dev is running in the foreground I have to use the port 9283 to access the port.
Now I want to access the rails app on remote machines like a mobile device or other PC. So have to use the ngrok to do so. I have installed ngrok in my ubuntu but I'm not able to access my localhost setup running on https://app.test:9283 using ngrok. Any help would be appreciated!
NOTE: When I use ./ngrok http 80 it successfully redirects me to localhost:80 which means ngrok is working properly.
With puma-dev it is necessary to include the -host-header argument, like so:
./ngrok http -host-header=app.test 9283
you have to bind the ngrok server with the same port as rails server ./ngrok http 9283
You need "local-leg HTTPS."
./ngrok http https://app.test:9283
I am trying to host a Rails app in AWS cloud where I have an EC2 instance and apache and mysql . Here I have uploaded my app but I am unable to bind it with IP. For a testing I am using this blog post https://www.digitalocean.com/community/tutorials/how-to-deploy-a-rails-app-with-unicorn-and-nginx-on-ubuntu-14-04 as a reference .
When I am trying to run this command :
RAILS_ENV=production rails server --binding=server_public_IP
I am getting this error :
/home/ubuntu/.rbenv/versions/2.2.3/lib/ruby/2.2.0/socket.rb:206:in `bind': Cannot assign requested address - bind(2) for 52.24.103.139:3000 (Errno::EADDRNOTAVAIL)
Is there anyone help me understand what is this problem and how to deploy it on AWS apache .
In AWS the machine is not directly assigned the IP, i.e. it is routed using NAT. hence you can not use the public IP to start your rails server directly.
To start server just boot it without the binding parameter rails s production
Or you can use 0.0.0.0 to bind your server, this will start your rails on all the interfaces.
Tip: For production you should ideally server using some web server like nginx/apache using passenger/unicorn
Looking from error it says it cannot bind with ipadd 52.24.103.139:3000
What I would suggest it to open a 'custom TCP port 3000' and try running the same thing again.
May be your app is working on port 3000 not 80.
Hope that helps.
I want to know what is this: localhost:8000, found in Codecademy tutorials for AngularJS and Ruby on Rails. I even installed Apache 2, but to work with it I need to dial: http://localhost/. While working on some html files, I often come across Firefox's Inspect Element where a section is to mention localhost and its number like this: localhost:8000. I want to know what's this and can I use it to access my host from my android device or some other PC as we do access Codecademy's localhost to learn AngularJS and Ruby on Rails. Pls help. Thanks in advance. :-)
Localhost is the loopback-address of your pc. The IP-address behind it is 127.0.0.1. With localhost, it is possible to simulate a web-server environment and it is mostly used to simulate running web-applications as if they are running on a webserver. :8000 stands for the port-number on which the browser connects to the server. This is because the application runs (in this case) on port 8000 of the server. So it is not enough to just install Apache 2 and surf to http://localhost/ you have to configure Apache so that it runs your web-application on the desired port. The port-number itself has no special meaning. The different ports are just a part of the url so the browser knows on which port it has to connect. Some protocols use default ports. (e.g. HTTP will always connect to port 80, unless your specify another port in your webbrowser)
I'm sure a lot of people can explain it much better, but here is a begin.
More info about running ruby on rails on an Apache webserver:
How can i run a ruby on rails project on apache server?
How to setup Ruby on Rails Hosting using Apache, from Development to Production
EDIT: Technically, the whole 127.0.0.0/8 address block is reserved for loopback purposes. The default one, configurged in hosts.txt is 127.0.0.1 and the most famous.
I am planning to have a web application.
To do so, I studied about ruby and ruby on rails. I am using linux server from amazon clouding system.
I bought a domain from godday, and I put the IP address on DNS setting. When I run 'rails s' command, I can connect to the wep page through port 3000 in such a way that domain.com:3000. However, I cannot directly connect to domain.com. How can I my domain works without port 3000?
And Do I have to run 'rails s' every time to make the wep page work? Actually I tried to use 'rails s &' to make it run in background. But it fails. How can I make the server run even though I am not connected to the linux server?
Thank you!
usually you use rails s just in development. there are quite a few ruby web servers you can choose from for your production environment: puma, passenger or unicorn to name a few.
of course all of them have their own tutorials how to set them up. for starters, i'd go with with passenger because it's integrated with nginx and apache and easily set up.
You need to specify a port, if you don't see the port it can be either 80 (http) or 443 (https).
rails server -p 80
On linux you have to be root to bind to port less than 1000, so just append sudo in front.
Can I acces my rails application which is running with rails s right now from another network?
I am using a dynamic IP address, and if I just go to http://whatismyipaddress.com/ and enter the IP provided there into the browser and end it with :3000, it will give a unable to connect error.
There's a gem called localtunnel. The easiest way to share localhost web servers to the rest of the world.
$ gem install localtunnel
$ localtunnel -k ~/.ssh/id_rsa.pub 3000
You should see something like this:
Port 3000 is now publicly accessible from http://8bv2.localtunnel.com ...