Apache as proxy not working for all sites - facebook

can somebody tell me why
ProxyPass /melonfire/ http://www.melonfire.com/
can work by accessing http://localhost/melonfire/ but
ProxyPass /facebook/ http://www.facebook.com/
is redirectig the browser to http://www.facebook.com/
Why? How could I make these redirections stop?

Related

Problem When Login To Piranha CMS Manager

I deploy piranha cms from my Debian development machine to Centos 7.9.2009 server. On development machine i don't have an issue to manager login. After login with default user dan password i directed to proper page. However, on the production server, after login to http://10.10.10.10:5010/manager the server refused to connect and i don't even able to access http://10.10.10.10:5010/manager page again until i clear the cache. The piranha.db on development and server are exactly the same. Piranha CMS Server using kestrel on port 5010. The home page accessible normally from http://10.10.10.10:5010. All other pages also accessible but manager. Here is my website conf:
<VirtualHost *:80>
RequestHeader set X-Forwarded-Proto "http"
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:5010/
ProxyPassReverse / http://127.0.0.1:5010/
ProxyPass / http://10.10.10.10:5010/
ProxyPassReverse / http://10.10.10.10:5010/
ServerName kid.domain.com
ServerAlias kid.domain.com
DocumentRoot /var/www/kid.domain.com/public_html
ErrorLog /var/www/kid.domain.com/error.log
CustomLog /var/www/kid.domain.com/request.log combined
</VirtualHost>
Any advice highly appreciated
Could this be something to do with HTTPS? I know that I had an issue logging in to my manager interface when I hadn't realised that I was trying to access it via HTTP rather than HTTPS.
Is your server and/or your CMS requiring HTTPS somewhere along the line?

Redirect example.com/path to different server but keep example.com/path

I feel like this is pretty straight forward but struggling to find a clear answer.
All I need to do is point example.com/path to a different server and keep example.com/path as the URL.
My question is: does the receiving server need to have its own domain to receive the redirect?
So, for example I would use a sub domain and point example.com/path -> sub.example.com/path?
How would I do this? Or is there a cleaner way?
We've been advised to keep the path as is (example.com/path) for SEO and not use a sub-domain (although, I suppose it's fine for redirect purposes).
Add this to your main site's Virtual Host configuration:
ProxyRequests Off
ProxyPass /path http://any.other.example.com/path
ProxyPassReverse /path http://any.other.example.com/path
For this you need to have mod_proxy enabled, with this line in your httpd.conf:
LoadModule proxy_module modules/mod_proxy.so
(but I believe it is enabled by default)

Mod_Security / Haproxy / Web servers (IIS)

I have haproxy as a load balance in front of my web servers(IIS), that works well.
Now I want to have mod_security configured with apache for request filtering and then pass the request to haproxy for load balancing.
I have already installed mod_security on centos, now how can I tell my WAF(mod_security) to forward request to haproxy.
okay I got it solved... add following lines to the httpd.conf file
ProxyPreserveHost On
ProxyRequests off
ProxyVia Off
ProxyPass / http://x.x.x.x:80/
ProxyPassReverse / http://x.x.x.x:80/
Note: Replace x.x.x.x with your actual IP

Vhost Zend Framework configuration MAMP - redirected to the index page of the server

I have checked out the posts and made the appropriate changes to the configuration files to make zend framework 2 to work on my local environment. Everything goes fine but the redirection of the page on specifying the vhost name doesnot work appropriately. It displays me the home page of the MAMP server with the directory listing.
Here is what I have done till now:
httpd.conf
<VirtualHost *:80>
ServerName newportalcopper.localhost
DocumentRoot /Applications/MAMP/htdocs/NewPortalCopper/public
SetEnv APPLICATION_ENV "development"
<Directory /Applications/MAMP/htdocs/NewPortalCopper/public>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
etc/hosts
127.0.0.1 newportalcopper.localhost localhost
Can some one tell me what i am doing wrong that this particular thing is not working.
Thanks for viewing the post guys and the help specified. At the end i was able to sort the problem out.
The main issue was the port number in case of MAMP. It was required to be 8888 instead of 80. This specifically solved my problem.

301 redirect in Passenger (Ruby on Rails) from root domain to www sub domain?

How can you create a permanent redirect (301) in Passenger? There are posts elsewhere on how to perform the redirect in Rails, but it seems better to do the redirect at the server level rather than at the Rails level.
Any clues?
Thanks!
Server-level redirects are done with the HTTP server, not the Application server. Here's some examples:
Apache
<VirtualHost xxx.xxx.xxx.xxx:80>
ServerAlias example.com
Redirect Permanent / http://www.example.com
</VirtualHost>
Nginx
server {
server_name example.com;
rewrite ^/(.*) http://www.example.com/$1 permanent;
}
Lighttpd
$HTTP["host"] =~ "^example\.com$" {
url.redirect = ( "^/(.*)" => "http://www.example.com/$1" )
}
While it's technically possible to achieve this later in the stack, like with a Rack app, it makes the most sense to do this as early as possible to save your server cpu cycles. Sometimes you have to do this later, for instance with a host like Heroku that won't let you change your HTTP settings, but if you have the option to do it here that's what I recommend.
Are you sure you want it at the Passenger level and not at the Nginx/Apache level... i.e., why have the redirect even get that far down the stack.
Depending on what server you are using, there are resources on the net that tell you how do accomplish this.