I am very new to consul and have registered a service with consul with following configuration.
{"service": {"name": "wrapper", "tags": ["consul-wrapper"], "port":8000,"address":"127.0.0.1",}}
I have also set up dnsmasq so that dns queries get resolved by consul server running on 127.0.0.1:8600
Now whenever I try to access my service like wrapper.service.consul it gets resolved and goes to port 80 instead of 8000.
What am i missing here?
You have to ask DNS specifically for the port number... it's an SRV request.
by default DNS queries are A(or AAA for ipv6) queries, and you just get the IP address.
try asking for the SRV record directly like so:
dig SRV wrapper.service.consul
Related
I have a basic web application running on a port in an EC2 instance. I have also created an A record in Route53 which points a domain name that I own towards the ip address of the EC2 instance.
When I directly access ip-address:port, it works fine, but because the a record does not point towards that specific port, the website cannot be accessed through the domain name.
How do I specify a port that all requests to that ip address should be routed to?
port is referenced by protocol you are using.
if you use http you will connect to port 80. https uses 443, ftp 21, smtp 25 and there are many others (they are called default ports for service but they may use every other defined).
You are probably running application, listening on some different port (but using protocol http) and that's why you can reach it by entering http://ip-address:port
what you can do to reach it by entering only http://ip-address is to set it to listen on port 80 (you will need root privileges to do this) or set redirect from port 80 to your applications port (you can use pure port redirection using iptables or (better) reverse proxy software. It can be apache as mentioned in comment above, or nginx or haproxy or something else (you haven't specified operating system anyway - those are mainly for linux).
Hope that helps
Let say you have to setup proxy setting in some app, but you don't know the proxy server IP and/or port. The browser setting says: automatic detection.
And there is no one around to give you the answer.
How to obtain the proxy server ip address
Go to cmd or powershell
run netstat
you will see a lot and a lot more connections.
The output shows columns like below:
'Protocol' 'Local Address' 'Foreign Address' 'State'
Foreign Address will repeat the same value many, many times. This is your proxy server for 99%. if there is only name simply ping the name to get the ip address.
4ex:
proxy:8080
ping proxy
proxy.mynetwork.local
10.0.0.250
setup the proxy in your app to
proxy server:
proxy.mytwork.local (or 10.0.0.250)
proxy port: 8080
try this list of servers here:
https://www.us-proxy.org/
or here:
https://whatismyipaddress.com/google-search?q=proxy+server+list&sa=Proxy+Server+List+Search&cx=013731333855297778374%3Absyy_h6slhu&cof=FORID%3A9&ie=ISO-8859-1
I am not able to successfully bind and secure the rethinkdb http client, either being exposed to the whole network or refusing connections behind the proxy.
I am thus left with no choice but to restart the rdb daemon with bind-http=all each
time I want to access it...
Rdb starts with systemctl under archlinux. Three configurations I tried:
# /etc/rethinkdb/instances.d/mydb.conf
bind-http=localhost #(1)
bind-http=127.0.0.1 #(2)
bind-http=1.2.3.4 #(3)
Resulting in:
Fails to parse 'localhost'
Refuses connections behind the proxy
Equivalent to bind-http=all
Firefox 59 uses a socks proxy, working ok
as the browser's ip address does become 1.2.3.4:
$ ssh -TND 8080 user#1.2.3.4
I am quite convinced that I had secured the http client as expected,
and problems started after I updated both FF and rdb
(FF59 fails to parse 'localhost' as well for example)
I don't know if this is a bug or a feature or if I am missing something,
any help is most welcome. Many thanks
Beware of the "localhost" string.
Configuring the rethinkdb server with:
#/etc/rethinkdb/instances.d/mydb.conf
bind-http=127.0.0.1
http-port=8084
and binding some local port with SSH:
[client]$ ssh -L 8080:127.0.0.1:8084 server
is enough to access the web interface at 127.0.0.1:8080, as suggested by #jishi.
Configuring the browser to use a SOCKS proxy as per the rdb docs is not at all necessary.
For some reason localhost:8080 is not understood by FF59 (gets invisibly prefixed by www or something).
I am using 0.10.1 version of Kong which supports SRV queries. I am using consul's dns and trying to integrate it with Kong. Looking at the documentation
https://getkong.org/docs/0.10.x/loadbalancing/
I am not sure how do I specify my upstream_url in kong
For example:
# This tries reaching my service on port 80 instead of the port returned by SRV query
upstream_url = http://ms.service.consul/ms
# As per the doc I can specify a port and it is supposed to proxy the port
upstream_url = http://ms.service.consul:8989/ms
What should my upstream_url config look like with SRV records from consul
upstream_url = http://myservice.service.consul:{{do_i_need_something_here}}/myservice
Will Kong be able to automatically detect the ports where my service is running or am I missing some important point.
Note: I am not asking about Consul HTTP port 8500. Can I call an API exposed by a microservice, which is discovered using Consul, just by the .service.consul/ WITHOUT specifying the port number?
I am using Consul for discovering multiple versions of a microservice. This microservice (written in Java) has port predetermined:
Service registered in consul as - my-service.service.consul (service port is, let us say 3030). I have another version of the same micro service registered with consul: my-servicev2.service.consul (port 3033).
Service definition (altered for the example):
{
"Address": <IP address>,
"CreateIndex": 111,
"ModifyIndex": 000,
"Node": <node name>,
"ServiceAddress": "",
"ServiceEnableTagOverride": false,
"ServiceID": "my-servicev2",
"ServiceName": "my-servicev2",
"ServicePort": 3033,
"ServiceTags": [
"v2"
],
"TaggedAddresses": {
"lan": <LAN IP>,
"wan": <WAN IP>
}
}
I can ping and dig the service using dig #localhost my-service.service.consul' orping -c2 my-service.service.consul`
But, how can I access one of the APIs exposed by this microservice without explicitly using the ServicePort?
Here is what is working:
curl http://my-servicev2.service.consul:3033/health -> resolves the service name, maps it to one of the deployed VM IP, and gives back the API response. In this case something like: `{"build"`: 'OK"}`
However, I should be able to access the API without specifying the port number like this:
curl http://my-servicev2.service.consul/health ->{"build": "OK"}`
Is this possible in Consul?
I've tried registering the service without Port value, and it added 0 as port value.
No in this case consul is acting purely as a DNS server and returning a healthy instance's ip address. As you have seen with your dig and ping commands.
You have to specify port as you did with your curl call.
To hack this you could modify your application to run on http default port 80.
If this is not possible you can setup what is known as a reverse proxy.
Nginx works great for this. Here is a snippet of a configuration that will allow you to handle this:
location / {
proxy_pass http://127.0.0.1:3033;
}
This will pass all your port 80 calls to localhost port 3033. Then your curl calls would work as expected without specifying port.