Access virtual machine from remote server - virtualbox

In my work we use VirtualBox for development so sometimes it gets a little bit tricky when it comes to testing.
Actually I'm working on a payment platform and I have to integrate with PayPal Instant Payment Notifications.
The idea is that when a Paypal transaction is approved, PayPal sends an IPN message to my server and that is the problem.
Is there a way I can make my local development server available so PayPal can access it?
Thanks in advance.

I assume your server is running inside the VirtualBox, right?
So you will have to give the VirtualBox machine an IP that your company router can relay the PayPal IPN message to. That IP should also be a static IP (not by DHCP) so the routing on the router could be set accordingly.
(The following works well, I have done it successfully numerous times)
To do that:
Setup the VirtualBox to have the IP from the company router: In VirtualBox adapter go to the 'settings' of that said VirtualBox, click on 'Network' and change 'Attached to' to 'Bridge Adapter'.
Launch the VirtualBox and change the IP of the machine to a static IP allowed by the company router.
Create on the company's router a routing ('Virtual Server') from a specific socket to this static IP. For example, for socket 1234: http://YourDomain.com:1234
Then you give the PayPal server this domain with socket. any communication on this socket would be routed directly to your server inside the VirtualBox.
Hope that helps!

Related

Can a remote server send response to a local client on a custom port?

For network gurus out there, I'll like to ask some questions regarding some unique setup where the server will be sending a request to a client on localhost on a certain port.
I have a cloudy understanding of some network fundamentals that I hope you'll be able to help me out.
Kindly check the image below:
Basically, there's a static website hosted in AWS s3 and at some point this website will send a request to https://localhost:8001.
I was expecting that it will connect to the nginx container listening on port 8001 in my local machine, but it results in 504 gateway error.
My questions are:
Is it possible for a remote server to directly send data to a client at a particular port by addressing it as localhost?
How is it possible for the static website to communicate to my local docker container?
Thanks in advance.
In the setup you show, in the context of a Web site, localhost isn't in your picture at all. It's the desktop machine running the end user's Web browser.
More generally, you show several boxes in your diagram – "local machine", "Docker VM", "individual container", "server in Amazon's data center" – and within each of these boxes, if they make an outbound request to localhost, it reaches back to itself.
You have two basic options here:
(1) Set up a separate (Route 53) DNS name for your back-end service, and use that https://backend.example.com/... host name in your front-end application.
(2) Set up an HTTP reverse proxy that forwards /, /assets, ... to S3, and /api to the back-end service. In your front-end application use only the HTTP path with no host name at all.
The second option is more work to set up, but once you've set it up, it's much easier to develop code for. Webpack has a similar "proxy the backend" option for day-to-day development. This setup means the front-end application itself doesn't care where it's running, and you don't need to rebuild the application if the URL changes (or an individual developer needs to run it on their local system).

Configure my local flask server to be available to other devices under same wifi network

From most of the resources, I gathered-
If I declare 0.0.0.0 as host and 5000 as port explicitly,other devices under my wifi network should access it, but when I type http://0.0.0.0:5000/ from another machine(my windows laptop), it didn't work.
port 5000 needs to be open. If not then I should open that.
That didn't work for me either.
Perhaps debug=True parameter should be removed from Flask's run() method as dev server shouldn't be publicly available. Still no luck!
What else could be the problem as the following isn't working for me-
app.run(host='0.0.0.0', port=5000)
I know, this question has been asked couple of times, but none of the suggestions worked for me. So, please help me access my flask Restful API through other devices as I want to test the service having a web application and mobile application as clients.
The Flask dev server should not be used in production as it is not designed to be efficient and secure. Flask Deployment
To make the flask dev server visible on LAN/WLAN add the host parameter to run on machine's IP Address
app.run(host='0.0.0.0', port=5000)
To Access the web server use private ip address(LAN/WLAN) of the machine running the flask server 192.168.1.23:5000

How can I enable my laptop to receive HTTP requests over port 8080 on my private network?

I'm behind a router and I have a web service hosted on Tomcat on my laptop. It's running on port 8080. I want my phone, also connected to my home network to be able to send HTTP requests to my laptop on port 8080. I installed a REST service app on my phone that allows me to send customized HTTP requests to wherever, and I tried sending it to 192.168.1.20:8080/web-service/test, where 192.168.1.20 is the address of my laptop on my home network and /web-service/test is the url I'm using to interact with the web-service, but I keep getting an "invalid request" message. When I access the web-service through that url using localhost:8080/web-service/test on my laptop the text that's printed in the browser is "running," but not when accessed through the phone.
I also tried pinging my laptop from my phone using another app and the ping is successful. The firewall is turned off and network sharing is on (windows 10). Anyone have any idea why I cannot access the web-service using 192.168.1.20:8080/web-service/test?
the problem was with the rest api testing app i was using on my phone. for some reason it was showing me an "invalid request" message even if the same url worked when i visited it from the chrome app. but basically it was working the entire time.

Port blocked creating web app on AWS

I'm trying to create a web app on AWS and I'm running into port issues. I would like to have multiple apps providing different services on different ports. I've created a website (on the same instance) to receive a text query and pass it to my app on port 3000. The app listening on 3000 is written in CherryPy.
We are using a VPN to provide security for the AWS instance. When logged into the VPN, everything works fine. The web page loads, the query returns the correct data. When I disconnect from the VPN, or someone else goes to the page, the page still loads, but queries to the service time out.
I've used netstat to make sure the service is listening but I'm not sure what could be blocking traffic. I've worked through the CORS issues as evident by the fact it works when I'm signed into the VPN.
What can I check now?
When I disconnect from the VPN, or someone else goes to the page, the page still loads, but queries to the service time out.
My assumption is that the web server and the app are on the same server.
It sounds very much like the connection from web server to app is happening via a routed IP address rather than localhost. In addition to being slower, it's also hitting your firewall rules.
Configure the web server to access your app on localhost:3000 and the issue should clear up.
I actually got it working. I have an AWS instance with nginix and CherryPy. When the user goes to a web address, the nginix page loads with a form for a query string. When they submit a string, the string is POSTed to a CherryPy service running on port 3000. The CherryPy service does some computations and returns a result via JSON.
I thought I had opened up everything completely for testing, but I was having so many issues. It turned out that having CherryPy set
"Access-Control-Allow-Origin" = "*"
wasn't working, instead I needed to specifically set the origin of the calling page.

Resolving DNS with winsock, with server behind router

I recently started to play around with sockets in windows and I ran into a bit of trouble..
I have an application that I want to find a host with DNS name resolution (through an internet connection).
The program manages to resolve the DNS name to an IP address, but the IP address it finds is the one of the router that sits in front of the computer that runs the server application(which is what I expect, since it is the default gateway)..
My question would be if there is a way to connect to the server application without having to modify the router's settings by hand every time the server application is installed on a system that has a router sitting in front of it.. Or is the only way to do this to somehow forwarding the port of the computer to the router ?
Any help is appreciated!
Thnx!
If the server is behind a router, then the router has to be configured for Port Forwarding. There is no getting around that. The router needs to know which machine on its network to forward incoming client requests to for any given port. However, depending on the type of router and its features, the server app might be able to configure the Port Forwarding programmably using uPNP or SNMP, if available and enabled. Otherwise, the router has to be configured by hand by the router admin.