I've got a utility domain out there (let's call it utility-domain.com) that generates short URLs and a site (let's call it prod-domain.com) that is attempting to call utility-domain.com to generate a short URL for it. They are on the same LAMP server, running CentOS 5.5. This is actually going to be a cURL in a PHP script, but before I get there, I am trying to just do a simple curl http://utility-domain.com while ssh'd into the server to see if it will resolve. I'm getting an error of curl: (7) couldn't connect to host. I've set the /etc/hosts file to point utility-domain.com to 127.0.0.1, and confirmed with a ping while ssh'd in that it is resolving to the local IP. Any ideas on how to get this to resolve?
I realize running this code locally would be better than doing a cURL to it, but the utility domain is used in other remote applications, so I'm trying to keep the scripts in one place.
Obviously the 'utility-domain' resolved (as otherwise curl would fail differently) but the curl error explains that there was no TCP server listening to port 80 on the IP that curl tried to connect to. You can easily verify this by checking which IP curl decided to use and then you can try telnetting to that IP + port instead of using curl.
This problem can be due to many reasons but possibly your Apache is not configured to listen on 127.0.0.1 (or "any" or whatever) so you have to make sure to reach correct IP. Or you have to modify your server config.
In some configurations, the IP of a host internally is not the same as the IP shown externally and that can also make things a bit tricky when you try to access your site without going through the external means.
Related
I am trying to expose my website to internet, using ngrok, my website lives in xampp server which is running on my local machine. the path to my website is this: C:\xampp\htdocs\TheWebsite
when i use the following command for running ngrok client:
ngrok http -host-header=rewrite TheWebsite:8081
the client gets connected to ngrok server, but when i try to access my website on internet using http://234k2h4k24.ngrok.io which is the url ngrok provides for me, i end up with this error:
The connection to http://234k2h4k24.ngrok.io was successfully tunneled to your ngrok client, but the client failed to establish a connection to the local address TheWebsite:8081.
Make sure that a web service is running on TheWebsite:8081 and that it is a valid address.
The error encountered was: dial tcp: lookup TheWebsite: no such host
how exactly one should set the value for -host-header switch in order to to get the sub-directories (websites) living in htdocs folder in xampp server environment??
I have searched this site and also all over the Internet and i found some quick answers but they confused me even more. like this one:
https://helgesverre.com/blog/expose-local-webserver/
which doesn't even provide a small example
and this: Tunnel a localhost subdirectory through ngrok?
just the same as previous one (no example)
A real good answer needs to provide at least one complete example (i mean, if you want to answer this question, please provide a full example of ngrok command for the path of my website (TheWebsite). thank you
for this purpose i needed to define virtual hosts for each of my websites!
I found the answer in a related question at stackoverflow.com and here it is:
Tunnel a localhost subdirectory through ngrok?
this question leads you to this page which lets you know how to define virtual hosts in order for your local machine to identify where is the requested website, just take a look and you will learn in it no time. here is the page:
http://forum.wampserver.com/read.php?2,127757
although its for wamp but it is the same for xampp server too!
I have hosted website and api on apache server on linux machine. I am trying to access the api through node js (using request module)which is on the same network. From outside that network, the api is accessible and working fine. I have many apis on the machine and only few are throwing this error. Recent change which was made to server is changing the cookie domain from foo.bar.com to *.bar.com in php.ini file. The website is working good. There is not much load on the server too. Any help appreciated.
A "connection refused" error means a TCP connection can't be established, so the cookie domain change should not have an effect here.
Are you sure it's a Node.js "connection refused" error, and not, say, the API itself being able to connect somewhere else? Can you give us the exact error message, with any traceback, etc., context?
You say there are many APIs (assuming API servers) on the machine and only some fail (assuming you tested this from the machine that is having problems connecting to the API server machine).
Are the working servers on different ports compared to the non-working ones?
Do those servers work from within the network? You say they're working fine outside of it. (It's possible that your local network has a firewall policy that prohibits this local connection.)
Can you double-check that the non-working servers are actually running? (An easy way to establish this would be running ss -ltpn; it should give you a list of listening TCP ports and their associated processes.)
My server is on DigitalOcean cloud. I am using Ubuntu with Apache web server. My home computer is running Windows 7. I am using putty for terminal.
Followed all of the directions on https://laracasts.com/series/laravel-5-fundamentals/episodes/1. Made it up to 8:40, where it directs you to run php -S localhost:8888 -t public. I run that, then open a web browser and tried the following:
-http://mywebsite.com:8888
-http://www.mywebsite.com:8888
-http://mywebsite.com/learning-laravel-5/public
-http://mywebsite.com/learning-laravel-5/public/index.php
None of the above work.
In Google Chrome, the first two options where I list the port number, I get a page saying This webpage is not available. ERR_CONNECTION_REFUSED. In IE, I just get a page with big font saying "This page can't be displayed."
For the last two options, I just get a completely blank page. In the console, I get this error: Failed to load resource: the server responded with a status of 500 (Internal Server Error).
I'm trying to pick up a web app framework to broaden my php skill set. Can someone help me out? What am I doing wrong/what is the video tutorial missing that I have to do in order to get Laravel up and running?
php -S localhost:8888 -t public is meant for running a site locally, which is what the video is showing.
If you are using a Digital Ocean droplet with Ubuntu and Apache, you will need to configure Apache to use /public as the document root and have Laravel installed in the /var/www directory.
From there you can visit the droplet's IP address (http://XXX.XXX.XXX.XXX) instead of the domain name (unless you have configured the DNS for that domain name). You won't need the port in the URL either, since Apache will be serving it on the default port 80.
This probably is not the answer you want, but here's my advice based on setting up a few VPSs on Digital Ocean. Step back. Spin a new VPS. Keep your old one around, if you want, but start afresh.
Create a new droplet
Setup your SSH and PuTTY and make sure that works
Setup your FTP (if you're using it)
Setup your DNS
Setup your Apache config files. DO has a very good tutorial on this: https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-14-04
Now, work on getting your "Hello world" html page to show when you access your domain www.yourdomain.com, yourdomian.com. Don't fixate on ports at this point, just get a minimal server running. This might help too: https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-14-04-lts
Make an saved "image" of this basic working setup so you can spin a new VPS if you need to.
Now that you have a server that loads your domain index page, you can start to install your Laravel.
In a nutshell, I'd advise you to establish a stable working server platform before you try to install and launch a more complex technology like Laravel, or Rails, etc.
Tutorials often make complex technologies seem easy, the 10-minute expert, but there is tremendous complexity masked under the hood of these frameworks. Start simple and build on a server one piece at a time. You have to walk before you run.
I use Laravel often, but my experience with servers is more relevant here. Everything you've said indicates an access problem, and knowing how hosting companies work, they probably have that port blocked (along with all other non-standard ports).
You can test this using PuTTY, open it up and enter the host name of your server. Change the port to 80 and change close on window exit to never, then connect. Enter:
GET / HTTP/1.1
Host: yourwebsite.com
Then press enter twice and the server will process the result. It should show you the HTML of your home page.
Now try it again with port 8888 and see if you can even connect. If you can connect then it's not a port issue, but my guess is you'll get a fatal error Network error: Connection refused, which means the port is closed or blocked via firewall.
Even though DigitalOcean give you complete control over the server, the connection probably still runs through their firewall. It's possible that you have your own firewall, but otherwise if the server runs through their firewall and the port is blocked nothing you can do on the server will open that port.
did you try chmod -R 0777 storage ?
I have a client web application (A) who tries to get the information of another application (B) with a webservice.
I've been testing it in my local machine and all went like a charm. However, when I uploaded them to my server (CentOS 6, SELinux disabled, Firewall configuration checked) I get the following error:
wsdl error: Getting http://applicationB/?wsdl - HTTP ERROR: Couldn't open socket connection to server http://applicationB/?wsdl, Error (110): Connection timed out
Of course, "applicationB" is a valid URL.
They are in the same server. One is in appa.domain.com and the other one in appb.domain.com.
I've tried to call directly the IP of the server in stead of writing the domain name, but no luck with that neither.
If I check manually the WSDL URL, I get a well formatted WSDL file, so it's not the problem.
I've tried to connect external webservices and they work well, so I think it's a problem with having the server and client webservices in the same machine (or domain).
With that in mind, I've also tried to listen to port 81 and calling the webservice via this port, so the listening port and the requesting port would not be the same. No luck neither.
I'm stuck with this, and I cannot get more ideas to solve it or to find a workaround.
Anyone of you maybe have experienced this problem before and know how to solve it?
Thanks in advance for your time and answers!
EDIT
I've been trying to connect to my localhost webpage via command line, using Lynx browser from my server and I can't not access the page, even trying with its IP. It cannot be reached.
Maybe this could help to find out a solution.
Finally I got it working...
I post the answer here to be helpful for future users.
The problem was in the hosts server file. As #Amenadiel told me in a comment, it wasn't resolving the names.
I changed the hosts files and it seems it took more than I expected (I made the changes 3 days before and they weren't applied yet) so I discarded the hosts issues as an option. But it seems it was the only problem.
Why, then, didn't work neither when I tried to reach it using its IP? Well, it's because of the server nature. It's a server hosted in the Cloud, so it will be - for sure - a Virtual Machine.
It has a public IP (the one I was pointing to) and a private LAN IP. The server could not see the public IP, so if I was about to use one, it should have been the private (LAN) one.
Thanks again to all of you for your answers and your patience with this server side newbie!
I have setup a PPTP VPN server on AWS and everything works perfectly. When connected to my VPN e.g. www.getip.com shows the IP address of the VPN server.
So far so good...
On the same server I installed an Apache server where I run a PHP script to get me my own IP address:
$ip = isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
Regardless if I am connected to VPN this code shows my local IP. I am not using varnish or any similar caching.
Any idea why this is the case?
- Are the $_SERVER variables saved in the PHP session?
Your help is very much appreciated.
[UPDATE]
The problem is definitely linked to the fact that the VPN server and the PHP script are on the same server. If I put the script on a different server everything works as desired. If connected to the VPN I expect to see the public IP of the server (which is the VPN server at the same time).
If you are using a VPC, then there is a problem in that the local IP will be used for all communication inside the VPC. The Public IP (EIP I assume) does not exist inside the VPC, it is assigned to the network interface and only translated in the IGW going in or out.
This means that when you check with www.getip.com you get the EIP just as expected since you pass the IGW, but inside the local net you will only see the local IP. Also, PPTP VPN works as it also passes the IGW.
Amazon suggests that you use the FDQN, even if you are on the inside and look up the external FDQN, you will get the local IP.
I do not know how this is in the Classic EC2, but I can only guess its similar.
If you absolutely need to have the public IP, you find it by using the Amazon service for this:
curl http://169.254.169.254/latest/meta-data/public-ipv4
or
curl http://169.254.169.254/latest/meta-data/local-ipv4
(See here: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-instance-addressing.html)