How to set mod_proxy to serve some files while others to be served by apache [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 have enabled mod proxy to serve my jsp and servlets and it seem to work fine. So if i hit localhost, it takes request to tomcat and executes it. What is want is that servlets and jsp are forwarded to tomcat while php is handled by apache. Both JSP/Servlets and PHP files are in the same folder and I need to make a call from JSP?Servlet to PHP or may be vice versa as well. Now the problem is that PHP is also forwarded to tomcat it seems if I use following pattern -
ProxyPass /auto http://serv.corp.com:8080/auto/
All JSP/Servlets and PHP files are inside auto folder which is in webapps folder.
Kindly help me to route static content i.e. PHP to apache.

To server static content by Apache and remain files by appserver (jboss in my case)..
httpd.conf of Apache should look as:--
DocumentRoot /usr/local/apache2/htdocs
ProxyPass / !
ProxyPass / https://www.example.com:8443/
ProxyPassReverse / https://www.example.com:8443/
here for example /logo.gif will be served directly by
Apache from the /usr/local/apache2/htdocs/logo.gif file.
And everything else will be served by appserver.
Hope it will be useful

You want to use ProxyPassMatch rather than ProxyPass. Something like (untested)
ProxyPassMatch ^/(.*\.php)$ !

Related

Redirect domain to another domain and change url [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I have a website on
mydomain.eu
and i want to redirect
mydomain.com
and
mydomain.org
to mydomain.eu. I want the url in the address bar to change to mydomain.eu.
Are there multiple ways to do this?
For Example:
apache virtualhost
htaccess
dns records/domain forwarding from registrar
programmatically
other
Can you give an example of each?
The options you give are correct:
apache virtualhost
You can create a redirect here, when you do that you have to point the DNS records to the server where apache is running:
an example can be found here:
https://www.digitalocean.com/community/tutorials/how-to-create-temporary-and-permanent-redirects-with-apache-and-nginx
htaccess
Similar to the virtualhost solution except that he redirect is made in another file example: Redirect all request from old domain to new domain
dns records/domain forwarding from registrar
With a DNS record only you can't do a redirect it should always be used with a forwarding service or one of the other options given
programmatically
You can create a redirect in the code, you should point the DNS records to the server running the application and make your webserver listen to the domainnames.
example in PHP: How to redirect to another page using PHP
Cheers!

Same domain - 2 separate servers [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
I have a website that runs on a framework on a LAMP stack.
Now I want to extend this website by adding a bunch of new pages, but served from a different framework on a separate LAMP stack on another server that is prepared to handle more traffic.
I don't want this traffic to pass by the original website as it will be a burden to be processed by the framework. However, I can afford to have apache forwarding the traffic request to a specific folder forwarded to a separate server with a different IP address.
For example:
mydomain.com/ -> goes to server A,
mydomain.com/folder1/ -> goes to server B
How can I accomplish this with apache?
I can even afford setup a separated server to handle the separation of these request, so each server will only receive the requests it is intended to process.
Another option could be to set a subdomain like ww2.mydomain.com pointed to the IP of a separated server but will this affect my SEO ranking?
What are other options and what would be the best option for this case?
You are looking for ProxyPass directive.
Example location for mydomain.com virtualhost:
<VirtualHost ...>
ServerName mydomain.com
...
<Location /folder1/>
ProxyPass http://serverb/
SetEnv force-proxy-request-1.0 1
SetEnv proxy-nokeepalive 1
</Location>
</Virtualhost>

Pound & Apache: REMOTE_HOST contains host of proxy [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 have a server running Ubuntu 12.04 LTS, Pound 2.6 and Apache 2.2. I have also the apache module mod_rpaf (installed from https://github.com/gnif/mod_rpaf) installed and enabled to ensure, that in the variable REMOTE_ADDR appears the real user ip address and not the address of the proxy.
This works fine, but the variable REMOTE_HOST is not changed by mod_rpaf. This variable contains "localhost" and not the host of the given user ip address.
Can you help me, please?
Here is my mod_rpaf configuration:
root#perseus ~ # cat /etc/apache2/mods-enabled/rpaf.conf
RPAF_Enable On
RPAF_ProxyIPs 127.0.0.1
RPAF_Header X-Forwarded-For
RPAF_SetHostName On
RPAF_SetHTTPS On
RPAF_SetPort On
Thank you
Check theses answers on a previous question about a missing REMOTE_HOST:
REMOTE_HOSTS is a variable that may or may not be populated by apache (and it's better if it is not set, else it imply a DNS query by apache for every incoming request). So Nothing on your code should rely on REMOTE_HOST. No application should assume this variable will be there and correctly filled.
mod_rpaf does what it is designed for, documentation:
Sets REMOTE_ADDR, HTTPS, and HTTP_PORT to the values provided by an upstream proxy.
Now you have a working REMOTE_ADDR, which is the only variable you should trust, make a copy of it in REMOTE_HOST if you really wants that, and simply do it in your application code.
There is a bug in Ubuntu LTS 12.04 that prevents rpaf to work at all.
https://bugs.launchpad.net/ubuntu/+source/libapache2-mod-rpaf/+bug/1002571
workaround
in rpaf.conf replace
<IfModule mod_rpaf.c>
by
<IfModule mod_rpaf-2.0.c>

How to forward a subdomain to a new port on the same IP address using Apache? [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
I have a NAS/Server running at home 24/7 and run many different services on it. I have got a domain name pointing to it now, and was wondering if it would be possible to create sub-domains that point to different ports for different services. For example:
http://subsonic.mydomain.com --> XXX.XXX.XXX.XXX:4040
http://minecraft.mydomain.com --> XXX.XXX.XXX.XXX:25565
http://files.mydomain.com --> XXX.XXX.XXX.XXX:4082
I have a single D-LINK router that currently port forwards all these ports to my NAS/Server whose IP is 192.168.0.104.
EDIT: The server is running Ubuntu 12.04.
What service or proxy do I need to run that can recognize the sub domain and route the traffic accordingly? Or could I use apache virtual hosts to handle this, because these subdomains will come in on port 80, which apache is listening to? Or does virtual hosts not work like this?
Any information, ideas, or tips would be helpful/useful.
There are two ways to do this. You could use the VirtualHost section of your httpd.conf or you could do it in your .htaccess. (assuming that the subdomains resolve to the same IP as your webserver)
In httpd.conf:
<VirtualHost *:80>
ServerName subsonic.mydomain.com
redirect / http://mydomain.com:4040/
</VirtualHost>
In .htaccess:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^subsonic\.mydomain\.com$ [NC]
RewriteRule ^(.*)$ http://mydomain.com:4040/$1 [R=301]
Documentation:
- Guide to creating name-based virtual hosts
- Core, including VirtualHost and NameVirtualHost
- Redirect
- mod_rewrite guide

apache virtualhost SSL + non-SSL [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
I'm having trouble figuring out what's the proper way to setup a SSL virtual host + a non-SSL copy of it.
I have it like this now:
<VirtualHost myip:80>
plenty of directives here
</VirtualHost>
and
<VirtualHost myip:443>
same directives as above
</VirtualHost>
And it works fine but every time I edit the directives in one of the vhosts, I must do it in the other as well. Anything cleaner and more elegant?
To run a website on both HTTP and HTTPS URLs, your only option is to run 2 separate VirtualHosts with the same DocumentRoot.
If the directives context allows, you can keep some of the common settings in a .htaccess file in a folder that is parent to both DocumentRoots.