REST calls not working on AWS with localhost? - amazon-web-services

I'm running a Spring application on an AWS box. The app is being hosted with Tomcat 8 and the build is running great. However, the calls we are making to the back don't work using localhost but do work when we use the ip instead.
Shouldn't we be able to use localhost instead of the ip? Is this a configuration issue with Tomcat 8 on our box and if so, what do we need to fix?

One reason can be a configuration issue in Tomcat, however, i think there is a higher probability of a missing configuration on the machine itself. I guess this is a Linux box, maybe a line missing in /etc/hosts (like the one below)?
127.0.0.1 localhost

Related

Hosting Back end Application with API on EC2 instance

I'm quite new to AWS and I have been starting to work with EC2 instances. I have a web application that has a frontend and backend separately. So first I hosted the backend application on EC2 instance and it is a Symfony framework based REST API Application. So I have installed all dependencies and now the application is running. But to check the application I ran some API calls to the application using postman and seems application is not working as intended. I get following response from Postman. I have also provided security group configurations properly.
When I start sysmfony app it says [OK] Server listening on http://127.0.0.1:8000.
Can't figure out why this is happening. Can someone help me here?
You are running your application trough CLI (Symfony web server bundle) , by default this will bind to 127.0.0.1 which can't be accessed from outside. To fix this, you must bind to your server's public IP/hostname and port:
php bin/console server:start 192.168.1.1:8000 # replace with your ip
You can also bind to all your IP addresses using 0.0.0.0
But keep in mind, you should not use built in server for production, it's slow and less secure. Use a real web server instead, like Apache or Nginx.

Jenkins configSubmit postBack aborting

Jenkins does not save any configuration when I make changes and click on "Save". I loaded the page on Firefox with Firebug, and I see that my postBacks are being aborted. I tried it on Chrome, and I get a "No data received". What am I doing wrong?
I installed Jenkins on an EC2 instance, and configured it to listen on port 8888. I opened the port on the EC2 console, as well as in iptables.
I then installed Apache2 and used it to provide a Proxy on port 9001, and opened that port as well, both in the EC2 inbound rules and in iptables. (When the setup starts to work, I'll close one of these ports.)
Jenkins is accessible through both ports.
Edit: I've also tried disabling iptables, the problem persists.
Edit: I've realized that the problem is with accessing Jenkins from outside. I logged in via SSH and accessed the site using elinks, and everything worked fine. However, elinks, being a text-browser, is a pain to use, and not all of the site is really usable this way.
After trying for several hours, I decided to try doing this on a different internet provider. Voila, things started working. I assume this is a problem with my Internet Service Provider, as this works perfectly on my work network.

Consume web services via LAN

I have web services running on my machine on a local network. Instead of connecting to them via localhost, I'd like to be able to connect to them via local IP - in this case 192.168.1.5. Once I can do this, I'll know other devices on the network can consume these web services too (in particular, my android phone).
In my project setup in Visual Studio 2013 (I am using IIS Express), if I set the project url to be http://testdomain.com:52252 and set the line in my hosts file for 192.168.1.5 testdomain.com, then connecting to testdomain.com:52252/testservices.asmx works just fine. However when I change the project url to http://192.168.1.5:52252/ and connect straight to 192.168.1.5:52252/testservices.asmx it returns Bad Request - Invalid Hostname. HTTP Error 400. The request hostname is invalid.
What is an effective way of testing web services on a local network? I need to develop and test web services and test them from an android device, but I am disallowed from developing/testing them on a live server at the moment. Are there any solutions to this?
I have looked for solutions online but have been unable to find any. I find it hard to believe there is not a common solution to this issue - surely people must have a way to test web services without hosting a server or connecting via localhost?.
I really see there being two routes to take
1) Route each domain to a vlan with it's own ip
Virtual LAN - https://en.wikipedia.org/wiki/Virtual_LAN
Configure VLANs in a Microsoft Windows Environment - http://docs.oracle.com/cd/E19407-01/820-7898-11/z40001c91004554.html
2) Create x number of virtual machines and simulate traffic
I've got it - I had heard others needing to turn off their firewall in order to get this to work. Personally I was using McAfee to manage my windows firewall - so I'd turned McAfee firewall off assuming that was enough - but I was wrong. Despite turning the firewall off, I still had to go into the advanced windows firewall settings and add an inbound rule to allow all incoming connections over the specified port. It then worked - I could call web services from other devices on the network!
The key is to edit the IIS Express file called applicationhost.config. Add a binding just like localhost, but with your IP address. Note that you have a binding configuration for each VS2012 project so put it in the one you are using.
Then right click IIS Express in the sytem tray and exit. Exit VS, then open it using Run As Administrator. That should do it.
<bindings>
<binding protocol="http" bindingInformation="*:24486:localhost" />
<binding protocol="http" bindingInformation="*:24486:192.168.4.104" />
</bindings>

How can i allow people in my local network to access the web service in my machine?

I have coded a web service using the Axis 2 framework and I can successfully invoke it using a test client (SoapUI) on the local machine after publishing the application in JBoss 5. I can post to the WS endpoint from the local machine and get the expected response.
Now i want to allow other machines to access the web service.
i changed the "localhost" to "my own fixed IP" adress at the end point location, and turned firewall off, but impossible to access the WS.
Note : windows Xp SP3.
Any idea ?
Thanks in advance !!
Please ensure you follow below steps
For example, if your ip is 10.132.243.54
List item
Checking if your IP is pingable by other systems
Instead of running with eclipse, run your jboss from your
command-prompt
start jboss-server suffixing -b in run.bat. The command is run.bat
-b 10.132.243.54
Access the WS from SOAP-UI using IP and not using localhost
If your IP is still not pingable, turn off the firewall, after
following above steps
Sorry for the late reply, However this would solve the problem i guess

WebApp accessible via localhost but not 127.0.0.1

i'm running a webapp on Jetty with Maven on my machine (Win7 pro X64) and i'm experiencing some weird problems:
when i try to open it on my browser - it's accessible via localhost but not 127.0.0.1 or my local address (192.168.0.14).
when someone else from my local network tries to access the app he can do it via my computer name but not via my local address.
NOTE:
ping works for localhost and 127.0.0.1. also, i can access 127.0.0.1 (80) with telnet.
windows firewall is off (stopped the service)
nothing defined in hosts file
cleaning DNS and ARP chache didn't help
on other computers in the network the app works fine and i can access it via their ip. we all share the same pom.xml.
error says - "link appears to be
please help me find out what the hell can be the problem
thanks...
after a looong evening of trying pretty much everything i think i found the problem - Skype!
after running jetty successfully on 8080 i consulted a friend and he told me about the skype issue. after shutting down skype, jetty runs perfectly on port 80 as well :)
after a quick search i found this - http://www.mydigitallife.info/disable-skype-from-using-opening-and-listening-on-port-80-and-443-on-local-computer/
NOTE: for some reason Jetty isn't throwing an exception like a server should in this situation
If you are getting genuine 404 errors, then you are obviously connecting to the Jetty server, but Jetty is deciding not to serve up your application on that address.
It sounds like you've enable virtual hosting on the Jetty server, so that the application is bound only to specific host names, and is therefore not being served up on numeric IP addresses.
I'm not sure how you've wound up in that situation though.