vagrant port forwarding does not work - virtualbox

I installed a precise32 VM using Vagrant in which I am trying to employ devstack for openstack developing. In order to access the service from host, I set up some forward ports in configure file but it does not work. That is I can not connect to 10.0.2.15 to which devstack prompted me to connect. I tried to switch the networking mode in VirtualBox from NAT to Bridge, then an error popped out saying something like "the NAT name already exists". I checked out the VirtualBox documentation but did not really understand. Anybody help me out please...
I add following to vagrant configure file:
Vagrant::Config.run do |config|
config.vm.forward_port 80, 9090
config.vm.forward_port 5000, 5000
config.vm.forward_port 5672, 5672
config.vm.forward_port 3333, 3333
config.vm.forward_port 8773, 8773
config.vm.forward_port 8774, 8774
config.vm.forward_port 8776, 8776
config.vm.forward_port 8777, 8777
config.vm.forward_port 9191, 9191
config.vm.forward_port 9292, 9292
config.vm.forward_port 35357, 35357
config.vm.forward_port 40529, 40529
config.vm.forward_port 47117, 47117
config.vm.forward_port 55977, 55977
config.vm.customize ["modifyvm", :id, "--memory", 8192]
end

If you have multiple ports to be exposed (port forwarding), it'll be better off using bridged.
Basically you need to enable Public Network in the Vagrantfile, add the following to the config block
config.vm.network "public_network"
See doc: http://docs.vagrantup.com/v2/networking/public_network.html
NOTE: you can leave the default NAT there, vagrant will add a 2nd virtual network adapter.
Once vagrant up completes, vagrant ssh into the box and do a ifconfig -a to get the IP address of the 2nd interface, you should be able to access the services from the host (as they are within the same network / LAN) as long as they bind not only to loopback.

I use Vagrant Version 2 with the precise32 vm and use port forwarding successfully as indicated by their documentation
Vagrant.configure("2") do |config|
config.vm.box = "precise32"
config.vm.network "forwarded_port", guest: 8080, host: 1234
end
Then I access using localhost:1234
Hope this helps.

Related

Remix provider connectivity issue with custom RPC

I have setup Ethereum private site chain using geth with the following nodes and each node is running on a separate machine on aws.
abc.122.41.xyz admin(node1)
abc.73.38.xyz peer(node2)
abc.125.123.xyz RPC(node3)
This setup is working fine with these parameters in geth.
--http.vhosts '*'--http.corsdomain '*'
But, I want to restrict access to specific sites to use this RPC like REMIX and etc. Now, I run the below command in this way to restrict access and I read it from REMIX official site to pass parameters in this way. But, Remix is not going to connect to the RPC and throw this error.
Error while connecting to the provider, provider not connected
geth --datadir node01 --networkid 4444 --nat extip:xyz.31.2.xyz --port 30303 --mine --miner.gasprice 1000000 --miner.etherbase=0x35ef1cb0552cEfDEDc9cF1DA19199071274094Ab --keystore key01 --ethstats node01:s3cr3t#stats-localhost.batterychain.info:3000
geth --datadir node02 --networkid 4444 --port 30303 --mine --miner.gasprice 1000000 --keystore key02/ --ethstats Geth/v1.10.20-stable-8f2416a8/linux-amd64/go1.18.1:s3cr3t#stats-localhost.batterychain.info:3000
geth --datadir node03 --networkid 4444 --port 30303 --mine --miner.gasprice 1000000 --http --http.corsdomain 'https://remix.ethereum.org' --http.addr 0.0.0.0 --http.api personal,eth,net,web3 --keystore key03/ --ethstats Geth/v1.10.20-stable-8f2416a8/linux-amd64/go1.18.1:s3cr3t#stats-localhost.batterychain.info:3000
I try to explore this issue on the internet and found some solutions like changing the order of parameters, and also passing REMIX with HTTP instead of HTTPS like
http://remix.ethereum.org
But, each time I face the above same error.

Can't access CyberPanel login on GCP with OpenLiteSpeed

I've installed Cyber Panel with OpenLiteSpeed on a GCP micro instance with CentOS7, and although I can access the OpenLiteSpeed Control Panel I can't access the Cyber Panel login, the latter timesout. I didn't use the 1-click CyberPanel image, instead I used:
wget -O installer.sh https://cyberpanel.net/install.sh
I've opened ports 7080 and 8090 as shown in the nmap report below.
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:7080 0.0.0.0:* LISTEN 1025/openlitespeed
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1025/openlitespeed
tcp 0 0 0.0.0.0:8090 0.0.0.0:* LISTEN 1037/lscpd (lscpd -
I saw another similar post from 2018 but without a solution at https://forums.cyberpanel.net/discussion/601/cyberpanel-cannot-be-accessed-from-google-cloud-platform
I didn't realise that OpenLiteSpeed came with it's own control panel, I had thought it would be simply a replacement for Apache, so I had thought I would just use CyberPanel to setup accounts/virtual hosts etc.
Any help in tracing the issue would be greatly appreciated. I only have limited experience with Linux/CentOS/Apache and no experience with OpenLireSpeed and CyberPanel.
I noted from another post that someone said installing using sudo would not work, so I deleted the instance, recreated, and installed using root user; made no difference.
At the end of the install I had missed seeing the list of ports that are required to be opened:
Please make sure you have opened following port for both in/out:
TCP: 8090 for CyberPanel
TCP: 80, TCP: 443 and UDP: 443 for webserver
TCP: 21 and TCP: 40110-40210 for FTP
TCP: 25, TCP: 587, TCP: 465, TCP: 110, TCP: 143 and TCP: 993 for mail service
TCP: 53 and UDP: 53 for DNS service
Although I had opened 7080 and 8090, I had not opened
TCP: 53 and UDP: 53 for DNS service
and
UDP: 443 for webserver
I believe it was opening UDP:443 that allowed the Cyber Panel login page load.
try
curl -I -XGET -k https://127.0.0.1:8090
if above returns 200/301/302 , then means panel page is OK
then
curl -I -XGET -k https://SERVER_PUBLIC_IP:8090
if above returns timeout or any error , that basically indicates firewall blocking it

python flask does not work behind HTTP proxy

I suspect the issue is the HTTP proxy in the server. But I am not sure.
I set up a hello world Flask app on Ubuntu, I was able to access the page by
elinks http://localhost:5000, # and
elinks http://127.0.0.1:5000, # but not
But NOT
elinks http://<server_ip_in_LAN>:5000 # I was also not able to remote access the page on another machine
Then I looked at my proxy settings, in /etc/environment, it has the following:
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
http_proxy="http://proxy-ip:8080/"
https_proxy="http://proxy-ip:8080/"
ftp_proxy="http://proxy-ip:8080/"
git_proxy="http://proxy-ip:8080/"
no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com"
HTTP_PROXY="http://proxy-ip:8080/"
HTTPS_PROXY="http://proxy-ip:8080/"
FTP_PROXY="http://proxy-ip:8080/"
GIT_PROXY="http://proxy-ip:8080/"
NO_PROXY="localhost,127.0.0.1,localaddress,.localdomain.com"
Further, I use ufw to control the firewall, port 5000 is allowed from anywhere.
And I was able to see the following by running nmap -Pn localhost
$ nmap -Pn localhost
Starting Nmap 7.01 ( https://nmap.org ) at 2017-08-04 21:09 EDT
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00016s latency).
Other addresses for localhost (not scanned): ::1
Not shown: 994 closed ports
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
3000/tcp open ppp
5000/tcp open upnp
5432/tcp open postgresql
8080/tcp open http-proxy
Nmap done: 1 IP address (1 host up) scanned in 0.09 seconds
However, if I run
nmap -Pn <server_ip_in_LAN>,
the "5000/tcp open upnp" line was missing, implying the port number seems only open to my localhost, but not open to LAN.
Why? How can I solve it?
Thanks in advance.
Flask often use internal host:
127.0.0.1
. So you can connect by server_ip_in_LAN by change host IP:
app.run(host= '0.0.0.0')
I have faced the similar kind of issue when I was trying to set my first pycharm project for flask.
Things you need to check
HTTP Proxy(if you are behind a proxy)
Verify the proxy details if proxy added
Check for port if not already used.
for flask specific(if you want to run on specific host and port)
app.run(host='0.0.0.0',port='5000', debug=True)
It gets started on 0.0.0.0 you can change it to localhost.

Accessing devops interface outside Cassandra EC2 cluster

I have just setup a four nodes Cassandra 3.4 cluster running centOS 7 on AWS. I was able to configure it and get all the nodes together. Now I would like to perform some tests, monitoring the cluster behavior using the devops center which I installed on one machine.
I thought using ssh-tunneling to access it from my computer:
ssh -i Amazon-EC2-Ami.pem -L 9999:localhost:8888 centos#public_address
Using my browser, localhost:9999 gets correctly tunneled to the devops login page: http://localhost:8888/opscenter/login.html, but I got a ERR_CONNECTION_REFUSED
I tried accessing devops on that machine using a command line browser and it displays the login page. I really do not know what the issue could be. Any information is truly appreciated. This is the cassandra-yaml configuration file, in case it helps:
cluster_name: 'Cloak'
listen_address:
endpoint_snitch: GossipingPropertyFileSnitch
rpc_address:
seed_provider:
- class_name: org.apache.cassandra.locator.SimpleSeedProvider
parameters:
- seeds: "172.31.55.186,172.31.55.187"
EDIT
Using the -v option launching the ssh tunneling I can confirm that the requests are correctly tunneled:
[centos#ip-172-31-55-186 ~]$ debug1: Connection to port 9999
forwarding to localhost port 8888 requested.
debug1: channel 3: new [direct-tcpip]
debug1: Connection to port 9999 forwarding to localhost port 8888
requested.
debug1: channel 4: new [direct-tcpip]
debug1: channel 3: free: direct-tcpip: listening port 9999 for
localhost port 8888, connect from 127.0.0.1 port 43846 to 127.0.0.1
port 9999, nchannels 5
Finally I managed to access it from my computer. I had to modify the configuration file for the operation center, located in /etc/opscenter/opscenterd.conf (only for package installation):
[webserver]
port = 8888
interface = 127.0.0.1
By default the webserver accepts requests only from the localhost. Probably it won't be the best option, but since the operation center allows to configure users, I set interface = 0.0.0.0, allowing any host to contact it.

Access rails server from host machine

My rails server (WEBrick 1.3.1) is set on the virtual machine (ubuntu 12.04) and use NAT. The default IP address is 10.0.2.15 with port 3000. How can I access from my host machine (win8) ?
I have tried to use port forwarding but it doesn't work.
Settings -> Network -> Port forwarding
Protocol | Host IP | Host Port | Guest IP | Guest Port
TCP 127.0.0.1 3308 10.0.2.15 3000
By setting your port forwarding as you did, you are telling your host PC that when you visit 127.0.0.1 at port 3308 in your browser, you want that resolved to be your guest virtual machine's I.P. address at port 3000.
With your virtual machine's Rails server running, open a browser on your host PC and navigate to 127.0.0.1:3308.
If your browser doesn't render your guest server's web pages, I'd suspect you have a port conflict (that port 3308 may already be in use). In that case, search for ways to view what ports are currently in use on your PC. Find a port which is not in use and use that in your port forwarding's host port settings.
If anyone faces the same problem, after port forwarding, I resolved this problem running the server binding the ip address of the virtual machine like this:
rails server -b 10.0.2.15