Proxy Pass: follow redirect on server [closed] - apache

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I'm using Apache ProxyPass to pass some requests from my server (1) to another (2). This works fine for most requests, but when server 2 processes a POST request and sends a redirect header, this is passed right through to the client, who then applies the redirect on server 1 and thus gets a 404.
So what I'd like is that server 1 (the server with the ProxyPass) follows redirects on server 2 and passes the final page back to the client.
I'm sure this must be a very common scenario, but I can't seem to find the solution. I'm imagining something like a "follow_redirects" flag, similar as you would apply to a curl client, but I haven't found anything like that. Maybe what I'm trying to do isn't the purpose of ProxyPass?
Could someone point me in the right direction here?
Thanks,
Chris

Check out the ProxyPassReverse directive. With this set Apache can intercept redirects and rewrite them so the client doesn't leave the proxy. This will not process redirects on the proxy, but it will at least make the client send the redirected request back to your server instead of leaving you.

I found the Apache Traffic Server, which is a reverse-proxy made by Yahoo and given to the Apache foundation.
From this documentation:
Origin servers often send redirect responses back to browsers
redirecting them to different pages. For example, if an origin server
is overloaded, then it might redirect browsers to a less loaded
server. Origin servers also redirect when web pages that have moved to
different locations. When Traffic Server is configured as a reverse
proxy, it must readdress redirects from origin servers so that
browsers are redirected to Traffic Server and not to another origin
server.
I haven't tried this yet, but there are packages for Debian, Ubuntu and CentOS.

Related

How do I send requests for a specific domain to Apache without it serving that domain yet?

I have an AWS EC2 server that hosts 3 domains with Apache 2. This server sits behind an AWS ELB load balancer which sends it requests. If I want to update this server, instead of taking the server down, I can create a new identical EC2 server and install all the software using the same scripts that built the first server and when it is ready I can add the new server to the ELB and then remove the old server. This gives me zero downtime which is great.
But before I remove the old server how do test the new server to prove everything is working and it is serving those 3 domains? DNS points to the ELB for these domains, the ELB sendsthe requests to the server, and the Apache install on the server routes the traffic to the appropriate site depending on what subdomain was requested. Is there a way make a request to the new server via IP address since that is the only way to address it before it is behind the ELB but tell it I want to make a request to a specific subdomain? If not how else can I prove all 3 sites are running and working properly without just adding it to the ELB, removing the old server, and crossing my fingers?
P.S. Sorry for the poor title. Please edit it if you can think of a better one that better represents what I am asking.
Use ELB healthcheck to perform the check. I recommend you to enable Apache server status mod. Use health check against /server-status and if it returns 200 for certain period of time, ELB will mark the instance as active and healthy.

Block CNAME redirect from a domain I don't own [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Someone has registered a domain and is using a CNAME redirect to direct traffic to my site. Google is seeing this as duplicate content and it's affecting my rankings.
Is there anyway of blocking access for traffic that comes to my site through the domainnotundermycontrol.com redirect?
Thanks in advance.
"There is no BAD publicity."
The CNAME is solely a DNS tool. The request to you server should still be sending a request for the domainnotundermycontrol.com/somepage to your apache server once it gets you're IP from the DNS lookup. Apache will see the 'ServerName' as domainnotundermycontrol.com
It sounds like the domain which you CAN control has no filtering on server name, only ip, maybe. Create a vhost for the domainnotundermycontrol.com on your server to catch all requests to that server name and serve up an index file with links to legitimate page you want people to hit or just some adwords. Then it will no longer be caught by your other vhost.
Enjoy the free traffic.

Can't browse to my EC2 Instance [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I've just (about 1 hour ago) associated an Elastic IP to my instance at Amazon EC2. If I SSH into my instance and type lynx localhost I can see that apache is responsive because I see the It works page.
However, If I browse into my instance (both via the IP itself and via the public DNS Amazon has created for me), I get Oops! Google Chrome could not connect to.. bla bla...
Should I wait some more time (in case it's due to some DNS thing) or does this indicate something is wrong?
Thanks in advance
EDIT: When I ssh into my instance, I use the full IP address and it works... (the Elastic IP I mean).
You must config the firewall to open the HTTP port.
To be more specific, for AWS this is done via Security Groups. You should create one with the ports you need opened. In most cases that's the por 80 for TCP.
You can see how to achieve this on the documentation http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-network-security.html
First identify the security group of the Ec2 instance.
Next click on the security groups link in the bottom left nav.
Select the security group under which this EC2 instance lies,
and add Inbound rules by specifying the port or a custom port range.
For those of you using Centos (and perhaps other linux distibutions), you need to make sure that its FW (iptables) allows for port 80 or any other port you want.
See here on how to completely disable it (for testing purposes only!).
And here for specific rules

Hosting a website on a PC using apache(Xampp) [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
This is what I learned by doing some searching. These things were taken from many places. Please point out any missing things. (I have not yet tried this out, just want to clarify what I'm going to do)
For hosting I need to have a static IP. But my ISP provide dynamic IPs. So I used DynDNS (as Cuga adviced in this). I belive this will resolve my dynamic IP problem by mapping the domain name I choose with my current(dynmically assigned) actual IP.
Next is setting up my Xampp server. For this I need my computer's local IP which I can get using ipconfig (or ipconfig/all for full details) in Windows command prompt (lets say local IP is 192.168.1.6).Now I have to edit httpd.conf located in xampp/apache/conf folder. "ServerName" field has to be changed to 192.168.1.6:80.
This should allow anyone using the hostname i got from DynDNS to access my computers xampp/htdocs folder.
Please fill me in if there are missing parts.
Now I want to change the port that my clients can connet to my computer and the folder that I am going to host using it.
I know that I have to do protforwarding first and then configure apache to use that port instead of 80. Can someone explain me how to configure apache to use the new port.
And I want my clients who use my hostname I obtained from DynDNS, access some folder only that I specify (ex: xampp/htdocs/public) while I can access any file in xampp/htdocs using http://localhost/... . I think this what virtual hosts do. Can some one tell me how to do this.
Are there any solutions to the security issues that might arise and how to do this minimizing security issues?
Thank you.....
1) if you specify ServerName as 192.168.1.6:80, only people who use this server name will be able to access your machine - those on the outside network will not.you should use *.80
2) to make apache listen on a different port, you need to add "Listen" directive to your httpd.conf. for example
Listen 90
and change ServerName accordingly
3) to let outsiders access only folders you want them to access, you can protect the rest with an .htpasswd. or you'll have to create a separate virtual host.

Sites that do server aliasing for other websites to use an external platform

First of all, granted the question is not very descriptive - quite hard to summarise what I mean in the title.
Let me elaborate. On uservoice.com they allow users to have domain aliasing.
For example, these sites use domain aliasing:
http://feedback.bit.ly
http://feedback.topofblogs.com
http://feedback.neutex.net
None of them are hosting the uservoice platform independently.
So my question is, how do you think they're doing the user aliasing?
Do you think uservoice just have a lot of server aliases in the apache config or?
I'm very curious. I hope this question made sense.
Have a good day.
It depends what web server they're using. In order to do virtual hosting, which is what this is, you have to use HTTP 1.1, which sends the name of the server that the browser is requesting in the Host: header. So if the user requests http://www.foo.com/path/to/something then the request looks like:
GET /path/to/something HTTP/1.1
Host: www.foo.com
The web server can then look at "Host" to see how to handle the request.
From the Apache docs on Name-based Virtual Hosts:
...the first listed virtual host is the default virtual host.
Each of their hosted sites probably has set up a cname in their DNS configuration to point to a uservoice server. Uservoice probably just uses a default virtual host to handle them all. I doubt they add a new virtual host entry or server alias every time they add a new client. That requires an Apache restart.
EDIT: A quick HTTP HEAD request of one of the sites you listed shows me they are using nginx, and not Apache. Nginx probably has similar configuration capabilities as Apache. I've never used it personally.