Port Forwarding not working for web services in Virtualbox 5.1.2 - node.js

I have a node app running in a Centos 7 based VM on port 5000. When I open a browser within the VM, I can access http://localhost:5000. I am forwarding port 5000/TCP in Virtualbox too. Until very recently, I was able to access the same URL on my host. I am able to SSH into the machine, so I can assume guest addition is not to blame.
When I curl from the host, I get the following output:
curl -v http://localhost:5000
* Rebuilt URL to: http://localhost:5000/
* Trying ::1...
* Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 5000 (#0)
> GET / HTTP/1.1
> Host: localhost:5000
> User-Agent: curl/7.46.0
> Accept: */*
>
* Recv failure: Connection was reset
* Closing connection 0
curl: (56) Recv failure: Connection was reset
Curl from the guest is successful:
curl -v localhost:5000
* About to connect() to localhost port 5000 (#0)
* Trying ::1...
* Connected to localhost (::1) port 5000 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.29.0
> Host: localhost:5000
> Accept: */*
>
< HTTP/1.1 200 OK
< Cache-Control: no-cache="Set-Cookie, Set-Cookie2"
< X-Content-Type-Options: nosniff
< X-Frame-Options: DENY
< X-XSS-Protection: 1; mode=block
< Content-Type: text/html; charset=utf-8
< Content-Length: 13545
< ETag: W/"34e9-XRkZVDhS9RNYciepFhTD7A"
< Vary: Accept-Encoding
< Date: Wed, 10 Aug 2016 17:11:16 GMT
< Connection: keep-alive
<
<!DOCTYPE html>...
Port forwarding settings are shown below - only SSH works, although I have tried adding and removing host IP to the services I want to access.
How can I troubleshoot this further?
Might this be a problem with the latest version of virtualbox?

Turns out I had downloaded a newer version of the Vagrant Box which now enabled the firewall where previously it was not. A lazy workaround was to:
sudo systemctl stop firewalld
sudo systemctl disable firewalld
Alternatively, to allow traffic outbound on port 5000 only
firewall-cmd --zone=public --add-port=5000/tcp --permanent

Stopping the Firewall Daemon in VM machine just worked for me. Thanks #Harry King
sudo systemctl stop firewalld
Curl result before disable:
* Recv failure: Connection was reset
* Closing connection 0
curl: (56) Recv failure: Connection was reset
After disable:
< HTTP/1.1 404
< Content-Type: application/json;charset=UTF-8
< Transfer-Encoding: chunked
< Date: Fri, 30 Oct 2020 06:47:43 GMT
<
{"timestamp":1604040463217,"status":404,"error":"Not Found","message":"No message available","path":"/"}* Connection #0 to host 127.0.0.1 left intact

Related

anyway to configure a URL prefix for prestosql web UI

Given prestosql cluster started and listens to localhost:8080, I found it redirects request to http://localhost:8080/ui/
> curl -v http://localhost:8080/
* Trying 127.0.0.1:8080...
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET / HTTP/1.1
> Host: localhost:8080
> User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:68.0) Gecko/20100101 Firefox/68.0
> Accept: */*
> Referer:
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 303 See Other
< Date: Thu, 02 Jul 2020 14:07:10 GMT
< Location: http://localhost:8080/ui/
< Content-Length: 0
Is there anyway to support a prefix like /prestosql so that it can redirect request from /prestosql to /prestosql/ui instead of /ui/?
The scenario is about using a gateway in front of prestosql then routing requests via URL rewrite. E.g., Nginx/HAProxy or Istio virtual service.
It is not possible and would require quite some work, since Presto's UI HTML and javascript code and expects various resources available at /ui/... path.
See previous discussion at https://github.com/prestosql/presto/issues/3706

wget giving me HTTP 403 in Linux EC2

I have Linux EC2 instance when i am trying to download a file but getting 403
wget https://plugins.gradle.org/m2/org/springframework/data/spring-data-releasetrain/Moore-
SR1/spring-data-releasetrain-Moore-SR1.pom
Above giving me me HTTP 403 error.How should i trace where its blocking me to download ?
All proxies are set properly in my Ec2.
I tried traceroute but its not give me IPs. How to troubleshoot where its blocking me to download.
I have also open all outbound traffic in security group of EC2 but no luck.
Curl in debug mode give me below
$curl -v repo.jfrog.org
* About to connect() to proxy myproxy.xxx.com port 8080 (#0)
* Trying 1**.10*.**.**...
* Connected to myproxy.xxx.com (1**.10*.**.**) port 8080 (#0)
* Establish HTTP proxy tunnel to repo.jfrog.org:443
> CONNECT repo.jfrog.org:443 HTTP/1.1
> Host: repo.jfrog.org:443
> User-Agent: curl/7.29.0
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 403 Forbidden
< Cache-Control: no-cache
< Pragma: no-cache
< Content-Type: text/html; charset=utf-8
< Proxy-Connection: Keep-Alive
< Connection: Keep-Alive
< Content-Length: 913
< X-RBT-SCAR: 10.1**.5.2**:1141466989:1000
<
* Received HTTP code 403 from proxy after CONNECT
* Connection #0 to host myproxy.xxx.com left intact
curl: (56) Received HTTP code 403 from proxy after CONNECT

curl from one docker container to another gives 302 on Jenkins server, but works locally

I've got a docker-compose file with 3 services:
database
api
locust container to load test the api
This is my (simplified) docker-compose file.
version: "2.0"
services:
database:
image: ourcompany/postgres11
environment:
POSTGRES_DB: thedatabase
POSTGRES_USER: theuser
POSTGRES_PASSWORD: thepassword
api:
build: ./api
volumes:
- ./api/src:/app
ports:
- "8001:8001"
links:
- database
environment:
- DATABASE_HOST=database
- DATABASE_NAME=thedatabase
- DATABASE_USER=theuser
- DATABASE_PASSWORD=thepassword
- UWSGI_HTTP=0.0.0.0:8001
# and some more env variables
locust:
build: .
volumes:
- ./reports:/opt/reports
- ./:/opt/src
links:
- api
command: bash -c "locust -L DEBUG -f /opt/src/locustfile.py --host=http://api:8001 --no-web -c 25 -r 5 --run-time 15s"
When I run this locally on my laptop (Ubuntu 19.04) it works great. But when running this on our Jenkins CI server (Ubuntu 16.04), the locust container isn't able to call the api.
So I created this curl command to manually try the post:
curl -v -d '{"id":"260b748f-dad4-42ba-84b4-9084ea5d8304","count":"6.0","sensor":"AAG-1-4"}' -H "Content-Type: application/json" -X POST http://api:8001/v0/measurement/
I execced into the locust container on my laptop (docker exec -it ee470aaea287 bash) and tried the curl post from there, which worked perfectly (I had verbose mode enabled):
Note: Unnecessary use of -X or --request, POST is already inferred.
* Trying 192.168.208.3...
* TCP_NODELAY set
* Connected to api (192.168.208.3) port 8001 (#0)
> POST /v0/measurement/ HTTP/1.1
> Host: api:8001
> User-Agent: curl/7.58.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 407
>
* upload completely sent off: 407 out of 407 bytes
< HTTP/1.1 201 Created
< Content-Type: application/json
< Vary: Accept
< Allow: POST, LIST, GET
< X-Frame-Options: ALLOW-FROM *
< Content-Length: 511
<
* Connection #0 to host api left intact
{"success": "true"}
I then ssh'ed into the jenkins server and ran the curl request from outside the container with api replaced by 127.0.0.1. That worked perfectly again (similar output as above).
I then execced into the locust container on the Jenkins server and tried the curl post from there:
Note: Unnecessary use of -X or --request, POST is already inferred.
* Trying 10.240.2.1...
* Connected to 10.240.2.1 (10.240.2.1) port 8080 (#0)
> POST http://api:8001/v0/measurement/ HTTP/1.1
> Host: api:8001
> User-Agent: curl/7.47.0
> Accept: */*
> Proxy-Connection: Keep-Alive
> Content-Type: application/json
> Content-Length: 407
>
* upload completely sent off: 407 out of 407 bytes
< HTTP/1.1 302 Moved Temporarily
< Date: Wed, 14 Aug 2019 07:18:28 GMT
* HTTP/1.1 proxy connection set close!
< Proxy-Connection: close
< Via: 1.1 localhost.localdomain
< Proxy-agent:
< Location: http://www.api.com:8001/v0/measurement/
< Content-Length: 487
< Content-Type: text/html
<
<HEAD><TITLE>Moved Temporarily</TITLE></HEAD>
<BODY BGCOLOR="white" FGCOLOR="black"><H1>Moved Temporarily</H1><HR>
<FONT FACE="Helvetica,Arial"><B>
Description: <TEXTAREA READONLY rows="2" cols="75"> The document you requested is now http://www.api.com:8001/v0/measurement/. Please update your documents and bookmarks accordingly.</TEXTAREA></B></FONT>
<HR>
<!-- default "Moved Temporarily" response (302) -->
</BODY>
* Closing connection 0
As you can see that fails with a 302 redirect. There are a couple weird things in there:
it first talks about port 8080 even though I need to connect to port 8001. I don't expose those ports manually since that could conflict with other containers on the Jenkins server. As far as I understand docker takes care of this under the hood though.
it redirects to www.api.com. What part of the system does this?
I then tried pinging the api container from within the locust container, which works perfectly:
$ ping api
PING api (192.168.32.3) 56(84) bytes of data.
64 bytes from api_1.default (192.168.32.3): icmp_seq=1 ttl=64 time=0.127 ms
64 bytes from api_1.default (192.168.32.3): icmp_seq=2 ttl=64 time=0.056 ms
64 bytes from api_1.default (192.168.32.3): icmp_seq=3 ttl=64 time=0.065 ms
and telnet:
telnet api 8001
Trying 192.168.32.3...
Connected to api.
Escape character is '^]'.
Does anybody know how I can debug this further?
We figured out together with the thread creator that he runs a proxy in the network. Thats why it was not working.
A change in the docker environment variables does the trick:
- http_proxy=
- https_proxy=
- no_proxy=
So the proxy is disabled inside the docker-container.

Too Many Redirects on OpenShift after push

I have a node.js application running on openshift. After testing my code on a local environment I pushed it up to my instance on openshift. After doing so, I went to check those changes on the public site and my browser reported that I was getting too many redirects. I tried to look at my haproxy status and even that was getting too many redirects.
I have done some investigation and here is what I've found:
I checked my nodejs logs and my node server started successfully (no errors)
I've ssh'd into my machine and ran curl -vvv $OPENSHIFT_NODEJS_IP:8080 and I was returned my index.html as I should.
When I run curl -vvv http://minutepolitics-minutepolitics.rhcloud.com/ I get this response:
RESPONSE:
Hostname was NOT found in DNS cache
Trying 54.81.203.46...
Connected to minutepolitics-minutepolitics.rhcloud.com (54.81.203.46) port 80 (#0)
GET / HTTP/1.1
User-Agent: curl/7.37.1
Host: minutepolitics-minutepolitics.rhcloud.com
Accept: */*
HTTP/1.1 302 Found
Date: Thu, 23 Oct 2014 03:26:06 GMT
Server Apache/2.2.15 (Red Hat) is not blacklisted
Server: Apache/2.2.15 (Red Hat)
Vary: Host
X-Powered-By: PHP/5.3.3
Location: http://minutepolitics-minutepolitics.rhcloud.com/
Connection: close
Accept-Ranges: none
Content-Length: 0
Content-Type: text/html
Closing connection 0
Also, when I ssh into my machine and run /etc/init.d/haproxy start the output is: Starting haproxy: [ALERT] 294/230821 (134951) : Starting frontend main: cannot bind socket [FAILED]
From here, I don't know what to do or try to get this working again.
Any and all help will be greatly apprecaited! Thanks!!

Jenkins api not working - "Empty reply from server"

I am trying to use jenkins api on localhost, but the jenkins server is sending "Empty reply from server". Any idea what's wrong ?
curl http://localhost:8080/job/test/lastBuild/api/json?token=testing -v
* About to connect() to localhost port 8080 (#0)
* Trying 127.0.0.1...
* connected
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET /job/test/lastBuild/api/json?token=testing HTTP/1.1
> User-Agent: curl/7.24.0 (x86_64-redhat-linux-gnu) libcurl/7.24.0 NSS/3.13.5.0 zlib/1.2.5 libidn/1.18 libssh2/1.2.2
> Host: localhost:8080
> Accept: */*
>
* Empty reply from server
* Connection #0 to host localhost left intact
curl: (52) Empty reply from server
* Closing connection #0
I found the reason, httpport was set to "-1" because of which jenkins was sending an empty reply.
Before -
JENKINS_ARGS="--httpPort=-1"
After -
JENKINS_ARGS="--httpPort=65530"

Resources