How do I set up a proxy server behind a proxy server? - php

I'm running XAMPP on Windows and know that I could set up a proxy server by adding a few lines in httpd.conf and httpd-proxy.conf, but I wonder if there's a way to set up a proxy server that runs behind another proxy server, since my ISP cache files from some websites and I usually don't get the up-to-date data.

Related

Connecting to another Server on a LAN via PHP

I've got two Linux servers set up at the same datacenter. They're hooked up through a private switch, and they respond to each other on local IP addresses (192.168.0.N and 192.168.0.M).
Currently, I have a PHP file on Server N calling a PHP file on Server M via (basically) file_get_contents("http://$domain/$folder/$filename.php");, and that file runs a PHP script on the destination server. The problem with this, of course, is that it goes out over the internet, chewing up bandwidth in both the send and the reply. This is why I hooked them up with the private switch.
How can I set it up so that I can call the other file by replacing the $domain with the 192.168.0.M address? What settings do I have to change on Server N (Centos 6.6, running WHM and CPanel) in order for it to recognize that 192.168.0.M will shortcut to $domain's home folder on Server M?
This is commonly handled with split horizon DNS, where internal DNS queries get answered differently than external ones.
It's best to do this via a proper internal DNS server, but if you can't, you can adjust the hosts file on your servers (in Linux, /etc/hosts) to override the IP for the domain name.

Long running progam times out to proxy error over DMZ

I have set up a DMZ to run a web site. Most of the code is on an application server running Debian Release 7.0 (wheezy) 64-bit. I also have a web server running CentOS 6.5. It acts as a proxy for the application server. I have set up LAMP on both and my web pages are written in PHP. A PHP script on the web server calls a PHP script on the application server. The application server script calls a long running (> 1 minute) executable (that had been developed in C++). After 60 seconds (timed by my watch), the script fails with the following message.
Proxy Error
The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request POST /appServer/scriptName.php.
Reason: Error reading from remote server
Apache/2.2.15 (CentOS) Server at sitename.com Port 80
I commented out code in the application server PHP script and narrowed the problem down to the long-running C++ executable. I also ran the executable in the shell without any problems. So there is clearly a time-out issue and it seems to be associated with the web server. I have only recently replaced an old version of Ubuntu, with Centos 6.5, on the web server and I did not have this problem before I did that. Also, the PHP code is the same as before I made the switch and it did not give me this problem prior to that. So I am convinced that the problem lies with something on the web server and one of the setting I have, with php or apache, on the new system.
I edited /etc/php.ini, on the web server, and changed all of the uncommented-out 60 second time limits (max_input_time, default_socket_timeout, mysql.connect_timeout) from 60 seconds to 600 seconds. I still get the above proxy error after 60 seconds.
Solution.
On the (CentOS) web server, edit /etc/httpd/conf/httpd.conf
Include the line
ProxyPass /appServer/ http://[private IP address]/ timeout=600 Keepalive=On
Specifically add the
timeout=600 Keepalive=On
part.
I also restarted apache to be on the safe side.

javascript not working after server reboot

Earlier today I had an issue with my server and it crashed so I had to reboot. Since I rebooted it I've been seeing some strange behavior in some of my php pages. Particularly, some javascript stuff doesn't seem to be working at all. (There are some other issues, but I feel like they're stemming from the failing javascript.)
I'm still getting used to web programming and using servers, so I have no idea why this javascript wouldn't be working after the reboot. I can post the script here if need be - I don't know if this is just a generic thing or is going to be specific to my script.
For the record it's an Apache server on a Redhat machine.
The javascript is executed in the client browser not in the server, so as long as you did not make any modifications to the javascript files, there should not be anything wrong caused by the server.
Did you try accessing your website using another computer ?
From your comment it appears that the page is loading a javascript library from a network location which it cannot find (http://wks-l0000120674/nephiere/validation.js). Thus it will load if the client machine (not the server) is connected to the network AND the wks-l0000120674 workstation is up and on the network AND the client machine has rights to request files from wks-l0000120674. On the reboot you may have booted wks-l0000120674 off the network (assuming that wks-l0000120674 is part of the same network as the server and the server also provides DHCP services). Make sure you can still get to this location from the client machine.

setting up remotely accessible wamp server along with iis

I am new to Windows IIS and I need to run a php/mysql application on it. For local php development on windows, I have found WAMP to be the easiest.
But can WAMP be used in this case instead of installing php and mysql separately ?
This needs to be done on an ec2 Windows 2003 instance. So far, I have already tried installing WAMP and setting up apache to listen on port 8080 instead of 80. From inside the remote desktop, both IIS and WAMP work properly in parallel on their respective ports.
However, when I try to connect from another computer using the ip address http://184.**.***.***, IIS works fine serving the default web page but cannot connect to apache on http://184.**.***.***:8080.
Is it possible to use WAMP at all for this purpose and if yes, would there be any disadvantages in using it instead of installing php/mysql seperately ?
Edit :
I dont know if this is a problem of blocked 8080 port. To verify this I stopped IIS and configured apache to listen to 80. Even then http://184.**.***.*** doent show the WAMP homepage. IS anything needed to be configured in IIS ?
RESOLVED :
Added the port 80 in Windows Firewall Exceptions and it started working.
Also, its necessary to select "Put Online" in the WAMP tray otherwise it gives a forbidden response as suggested by some answers.
Thanks
I haven't used EC2 in this way before, but broadly speaking, I'd encourage you to use the same server for development and production environments if at all possible - the installation effort can be a bit of a pain, but it's nothing compared to developing an app locally and then finding an IIS configuration issue causes it to break on production.
This approach also lets you keep your PHP configurations in source code control - php.ini and any modules you're using - and automatically deploy them alongside your application; again, forgetting to deploy the correct PHP.ini usually makes your application do crazy things...
So, your choices appear to be:
- switch off IIS and have WAMP listen to port 80. Not sure WAMP is designed for production level traffic, but in the past, I've run low-traffic public websites in this way.
- work out why port 8080 is blocked, and if it can be unblocked. This would still require you to run your website on an unusual port, which makes for ugly and hard-to-communicate URLs.
- install PHP on your IIS instance. One benefit of having installed WAMP is that MySQL should already be up and running, and the basic PHP installation should also be there; getting PHP to run on IIS is no longer a dark art ([http://php.iis.net][1])
For my money, I'd go for the latter option...IIS is a production quality server, and it's clearly what Amazon want you to use in this instance.
Of course, running IIS on your development environment may be a problem.
Have you put the server online? Think it is offline by default, meaning it's only accessible from your local machine. It's an option in the systray menu to put it online.
If I remember well, there is an option "go public" (or "put online") on the system traya icon of wamp.
This option modifies the httpd.conf to authorize public access.
You should give a try.
On a side note, you can make php work with IIS. This is another option to help you manage your server. (Mysql and Php have to be installed separatly but, this is very easy to do as far as I remember :) )

Write transparent HTTP Proxy script in PHP

Is there an easy forwarding/transparent php proxy script that I can host on my web server? These are my conditions:
I'm using free web hosting, so I have pretty much no control over my machine. Otherwise I could use Perl's HTTP::Proxy module. This means no root password. It does run php though.
I already have a server running on port 80. What I mean is I would like to put a php script as index.php on my server that will forward all requests.
I don't want a script like PHProxy or Glype where I go to the site, then enter a URL. I want a server so I can enter proxy.example.com:80 in Firefox's or IE's or whatever's proxy settings and it will forward all requests to the server.
Preferably (though not fatal if not possible) I would like for it to pass on the USER_AGENT environmental variable (That's the browser) instead of setting itself to be the USER_AGENT
I can't start a new Daemon. My server won't allow it.
Is there a script that will do this? If so, which?
No, I'm fairly sure this is not possible on shared hosting. It will fail your condition number 3. This needs support on web server level (e.g. using Apache's mod_proxy)
For this to work, you would have to set up the remote server to be able to deal with proxied requests. No sane web server will offer that possibility.

Categories