Page display with URL Rewrite on Amazon Elastic Load Balancer (URL rewrite works but the page doesn't display) - apache

There is an issue with Page display with URL rewriting when the ELB handles the request. I have been using 2 instances and load balancer automatically processes the request using one of the instances. When I browse using the Public IP of any of the 2 instances independently, the URL rewriting works fine and page is rendered as expected. But, when I browse using the load balanced URL, the URL rewrite works but the page doesn't work and throws 404 error.
FYI, I have been using apache as web server on instance 1 and nginx as web server on instance 2. I think there shouldn't be a problem because of this.
Please suggest.

I could solve the issue. The problem is in the virtual host configuration of one instance with apache wherein the Public IP is specified. When I used the ELB address instead of Public IP, the issue is fixed.

Related

What is wrong behind my ALB on AWS that I get a 404 error (random)?

I have set an AWS application load balancer to redirect to IIS (ec2).
There will be more ec2 afterwards. For now, for testing purpose, I only redirect to this VM.
I also set an A record on Route53 pointing to the AWS balancer url.
Problem is that some times I reach the target, and sometimes I dont (with 404 error). Random.
For example, I visit:
http://labcac.netcontent.com.ar:8080/assets/css/bootstrap/bootstrap.min.css
It goes well. Once or twice. Third time, I get 404 error page.
Instead, If I use the public IP of IIS (instead of the Route53 record pointing to the ALB) it always works ok.
What am I doing wrong?
Listener

AWS Load Balancer giving 302 on include

I am trying to configure 2 EC2 instances on the top of a load balancer. Our Application is running on Apache and uses Coldfusion 9 as application server. Since we have placed a load balancer it has started giving 302 . But if we try to use the same form on stand alone instance, then it works fine.
The line ate which it has started giving error is this -
<cfsavecontent variable="sResponse">
<cfinclude template="views/region/#this.getRegion()#/#sResponse.data[2]['view']#" />
</cfsavecontent>
I am not sure how to fix this. Is there any apache configuration that needs to go here?
I found the solution. It was my mistake in the configuration of LB. I was not using sticky sessions and hence the LB was directing request to other instance on each request.

HAProxy + mod_pagespeed

I have currently 3 web server configuration with HAProxy dividing the traffic to one of each web server. Each server is running apache2 with mod_pagespeed. The HAProxy takes care of the SSL termination as the web servers are in local network.
HAProxy sets the X-Forwareded-Proto header to each request and I have enabled "ModPagespeedRespectXForwardedProto on" in each pagespeed configuration.
Apache services are running in custom port 8012 and now I am getting an error to javascript console from pagespeed when going to the site:
Mixed Content: The page at 'https://www.example.com/' was loaded over HTTPS, but requested an insecure script 'http://www.example.com:8012/_,Mjo.NZsywmsdso.js.pagespeed.jm.OLNkjPSHpv.js'. This request has been blocked; the content must be served over HTTPS.
Any idea what could still be wrong? Here is the pagespeed HTTPS configuration:
ModPagespeedFetchFromModSpdy on
ModPagespeedFetchHttps enable
ModPagespeedSslCertDirectory /etc/ssl/certs
ModPagespeedSslCertFile /etc/ssl/certs/cert.pem
ModPagespeedMapOriginDomain "http://www.example.com" "https://www.example.com"
ModPagespeedRespectXForwardedProto on
Any help is appreciated!
This question is old, but I am going to answer how I fix it on my own setup.
The issue comes if you are using pagespeed on each server vs somehow running it on haproxy itself for caching. Since pagespeed saves a copy of any modified file with a modification on filename, then it also changes the source of the HTML to match that new filename it stored, which should work fine. But the issue is that is pagespeed on web server 1 is modifying the HTML to match background compressing of the files(images, js, css, etc) then when it gets to the users computer and their browser requests such files it wont find it if you are round-robin it between servers because that file will be only on web server 1 and not on the others, the way around it is to use a shared folder for the pagespeed so when one compresses a file into that folder, the other web servers will see it through their pagespeed.

Browsing sites with their domain name from the same server they are hosted on

I have a co-located webserver(Win2k8) having a public IP and have hosted my ASP.NET website on the IIS. Though, I am able to browse everything else from the local browser(IE) installed on the server, the server somehow fails to browse the websites that are hosted in its own IIS when I access them using their 'domain name' set as a host header. For e.g: If the website is for "www.mywebsite.com", so naturally I have set the Host header property to "www.mywebsite.com" and when I put "www.mywebsite.com" in my IE address bar it fails to get the request.
Ok, so now why I need to access this website is that, I plan to send a Query parameter to one of the pages from another page of the same website.
Any idea how to get this working? Thanks in advance folks.
It may be trying to reach itself via its public IP address, which it may not be able to route to.
You can try adding a line into your hosts file (C:\Windows\System32\Drivers\Etc\Hosts, or equivalent) as follows:
127.0.0.1 www.mywebsite.com
Which will force it to access it via the loopback adapter.

What is the best technique for (seo-friendly) forwarding muliple domains to one web server?

The setup is:
www.domainA.com
www.domainB.com
both actually hosted on one web server (Apache)
123.123.123.123/domainA
123.123.123.123/domainB
I have setup a hidden forward from the domains to the web server directories which works fine, however, produces duplicate content (since it is also available by addressing the web server directly). I tried setting up 301 redirects to the domains for every request that is targeting the IP address directly (using mod_rewrite),but found that this results in a forwarding loop. Obviously the server does not recognize whether the domain has been requested originally.
If anybody can give me a hint on how this is supposed to be done, I'd be glad to hear.
You can set up virtual hosting on the web-server so that it does pay attention to the hostname that was requested. This is a fairly common practice and should solve your problem. You can do away with separate subdirectories since each virtual host has its own virtual root.
So are you saying that you have pages indexed in google that reference your IP address and a directory rather than the domain name?
Also, I'm not sure why doing a redirect from the IP to the domain name would cause a redirect loop. If the redirect is based on the host header, it should work fine.