How do you specify IP addresses for TravisCI's host addon? - travis-ci

According to TravisCI docs,
If your build requires setting up custom hostnames, you can specify a
single host or a list of them in your .travis.yml. Travis CI will
automatically setup the hostnames in /etc/hosts for both IPv4 and
IPv6.
But it doesn't say anything of specifying IP addresses. It also says nothing of the format for the host names. Is is possible to specify a simple alias, like myhostnamealias or does it require a FQDN? At least CircleCI mentions that it uses a FQDN (although I don't know why that stipulation exists, but that's a separate question.)
Thanks,
Robin.

By experiment I have figured out that the list of hosts provided in
addons:
hosts:
- travis.dev
- joshkalderimis.com
are all being set up to point to 127.0.0.1 equivalent to /etc/hosts entries like this:
127.0.0.1 travis.dev
127.0.0.1 joshkalderimis.com

Related

jgroup_bind_addr in Docker container

I am moving one application from server to docker in Azure infra. How to map jgroup_bind_addr for ever changing pod ip?
<TCP bind_port="${jgroups.bind_port}"
bind_addr="${jgroups.bind_addr}"
>
By default, Infinispan images bind to SITE_LOCAL which mean "Picks a site local IP address, e.g. from the 192.168.0.0 or 10.0.0.0 address range"
In the JGroups Configuration you can check other possible values available for bind_addr. Look for The following special values are also recognized for bind_addr after the table.

How to change 0.0.0.0:8090 address to mastery.local in docker

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.

etc/hosts with port number (fix for foreman)

I am using Foreman specifing port 3000. How can I access my application by writting myapp.local in the browser instead of typing 0.0.0.0:3000?
I have added:
0.0.0.0 myapp.local
But when doing myapp.local it defaults to the default localhost for Apache, not the Rails app.
Short answer: You can't.
The host table is meant to map hostnames to IP addresses (Wiki). Ports come in at a different point.
However, you can specify the port Foreman should run on:
-p, --port
Specify which port to use as the base for this application. Should be a multiple of 1000.
I don't know the Foreman but as you connect to it with your browser than I assume it talks via HTTP. If so you can use proxy settings to point to that host:port. Try FoxyProxy. It's more like a workaround rather than a real solution but it should work (as far as it's not HTTPS)
If you're using Linux than another way is to use LD_PRELOAD to overwrite connect glibc function. It's quite low level hack but it's not so complicated.
Another way in Linux would be to make netfilter rule (iptables) to NAT the connection. It's not nice either as you'll need root level change to achieve simple thing.

Requests through another machine

Is it possible to make requests for example with Savon through something like ssh-tunnel. I can run this stuff from my stage server whose IP is whitelisted in the service I'm sending requests to. But of course I want to do the development on my computer :P so is there any option to do that? I've already tried savon's proxy: option in many combinations such as
proxy: "http://name:password#my_stage_server.com"
etc. I'm using Ruby on Rails.
SSH tunnels are the way to go. They are easy to set up, use this in one terminal session:
ssh -L 8080:servicehost:80 myuser#stagingserver
Once established, leave it open. It'll open port 8080 on your localhost as a tunnel to the TCP service at host:443. Point savon to http://localhost:8080/some/url/to/service to access the service running on http://servicehost/some/url/to/service.
If you need this frequently, it's convenient to add it to your ssh config file, which is located at ~/.ssh/config. It's a plain text file, the example above would look like this:
Host staging
HostName hostname.domain
LocalForward 8080 servicehost:80
User myuser
With this configuration you can open the tunnel by simply issuing ssh staging. There are more options you could set, please refer to the MAN page for details.
Hostname resolution
Keep in mind that the hostname servicehost must be resolvable from your staging server, not your development machine. You can use IP addresses, too.

Adding 0.0.0.0 to /etc/hosts

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

Resources