I'd like to setup an Apache server proxy environment to achieve this: whatever [URL] you type in the browser, the Apache server "proxies" this to http://mydistantserver.com/[URL encoded].
Example: in the brower, I type http://amazon.com => goes to local Apache proxy, which internally changes it to http://mydistantserver.com/amazon.com then proxies it (=> calls http://mydistantserver.com/amazon.com and send the result back to the browser).
Is there a way to put ny rewriterule before it's used by the Apache server proxy module?
Oh by the way: my PC already uses a "global" proxy. So I'd like Apache proxy to configure its "workers" to use this "global" proxy otherwise they wont be able to make the requests.
Is there a way to put ny rewriterule before it's used by the Apache server proxy module?
No, Apache does not work that way.
Related
Is it possible to configure a vhost on httpd that accepts any domain received and proxies to the actual website? Like subdomain wildcard but for the domain.
I'm assuming that tools like Squid Proxy can do this just fine, I'm just curious if it can be done with apache.
Sure that is possible, but you don't even need a proxy for that. The apache http server offers the concept of a "default virtual host". Which is exactly what you want: that host is responsible to respond to incoming requests to http hosts that do not have a specific configuration.
The default typically simply is the first of all hosts defined inside an apache http server.
An alternative I personally use is to setup the virtual hosts by just a basic configuration (name, admin and the like), but to include the actual content configuration (DocumentRoot and rewriting stuff) from a separate file). That way you can easily share the same setup between many virtual hosts but still have individual configuration options per domain, subdomain, http host, however you want to call that (there is no difference for the http server anyway, it is all http hosts).
I want to achieve the following:
My app services user requests like so:
user request www.mysite.com -> Apache reverse proxy -> 192.168.1.1:8080/myApp
My app also makes requests but I want to route through a proxy:
192.168.1.1:8080/myApp -> Apache forward proxy -> www.google.com
Can I set this up on the same Apache server? If not, can I do it with two Apache servers on the same system?
My solution is to set up two virtual hosts in apache with different ports, one acting as a reverse proxy and the other, a forward proxy.
One conf file contains ProxyRequest on which makes Apache work as Forward-proxy and put ProxyRemote to localhost:high-port, and another conf file contains VHOST block for each port with ProxyRequest off which make Apache as Reverse-proxy.
I have the following question that I do not know how to solve it in the most efficient way.
I have two servers, one with Apache where I have a Wordpress instance responding for port 80, and on another server I have a Wildfly with another application listening on port 8080. The Wordpress that I have configured on the Apache server, responds to the URL http://www.somedomain.com What I'm not so clear about is how to do when a request arrives at http://www.somedomain.com/yyyy and redirects me to the Wildfly server where an application is responding to the URL : 8080 / app
How could I do it in the most effective way? Using the rewrite module in the .htaccess file or using the Apache proxy module and configuring it in the Apache virtual host? How would I have to do it?
Thank you very much in advance.
You're mixing a few things that are not related to each other. First of all, a redirect is something different than a proxy. Redirecting means asking the client (browser) to look at another URL. A proxy, on the other hand, retrieves the content of the other URL itself and passes it to the client. Using a proxy, the other URL remains invisible to the client.
Second, mod_rewrite is not limited to htaccess configuration. In fact it's better to configure mod_rewrite in the virtual host configuration, just as you suggested with the proxy configuration.
The htaccess is simply for users who are not allowed to mess with the server configuration itself. Configuration in the htaccess can be limited by the admin for security purposes at the cost of slowing down the server.
That said, if you are looking to map your wildfly server paths into your main server's paths, you might want to use something like this inside your main server's virtual host block:
<Location "/yyyy">
ProxyPass "http://wildfly:8080/app"
</Location>
See http://httpd.apache.org/docs/current/mod/mod_proxy.html#proxypass for detailed explanations.
I've got a problem with apache configuration. In short: there is a JBoss server with backend and Apache with frontend. Both are independent. There are requests, that are sent to the address like 1.1.1.1:8080/xyz (to the JBoss server) and I would like to make something like overwritting the 1.1.1.1 address with for example 'jboss' word. Just make it hidden for the person that will use the app and not making it necessary to give that person access to the JBoss server.
How can I do it? Should I try configure a VirtualHost or something different?
You can't rewrite to an external server but you can Proxy / Reverse Proxy the requests. Have a look at https://httpd.apache.org/docs/2.4/mod/mod_proxy.html
I have been trying to get this work for the last 2 days since I am relatively new to Apache server. This is what I am trying to do in my local machine.
I have installed Apache Server and it acts as a front gate for all requests and sends them to JBOSS server. This is through AJP method.
I have enabled the mod_rewrite in http.conf and I want to do a simple redirect in my localhost. Below is what I tried..
RewriteEngine on
RewriteRule ^first.html$ second.html
This is not working as the log says it is looking the files in the document root C:\Apacheserver\Apache2\htdocs and i dont have any files in this location as the file comes from JBOSS(For ex: C:/jboss4.0/jboss-4.0.3SP1/server/MyApp/deploy/unisysv2.ear/web-app.war).
How do I make this redirect work under this condition.
Thanks
You should configure "bridge" between Apache an JBoss. Use mod_jk module or mod_proxy for that purpose, which are implementation of ajp communication protocol between Apache and JBoss.