logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Two webservers (public and Internal) : A suggestion please Page 1, 2  Next
Author
Marge



Joined: 25 Aug 2009
Posts: 22

PostPosted: Thu 12 Nov '09 9:31    Post subject: Two webservers (public and Internal) : A suggestion please Reply with quote

Hello. I'm having 2 webservers in the following configuration, behind a firewall:

The webserver 1 is made public. The webserver 2 is only for internall use.
I want to redirect a page (or a link) from the webserver 1 to one php script from webserver 2, but the script must be runned on webserver 2 because it has all the requirements (programs) needed to run the script.
Also, if it's possible and if I'm not asking too much I want to be runned internally (using 192.168.1.3).
I don't know If I explained good, but if someone can help me, please do Smile


Last edited by Marge on Tue 24 Nov '09 18:47; edited 1 time in total
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7355
Location: Germany, Next to Hamburg

PostPosted: Thu 12 Nov '09 12:25    Post subject: Reply with quote

You could use the Webserver1 as a reverse proxy. than the script still can run on the second server.
Back to top
Marge



Joined: 25 Aug 2009
Posts: 22

PostPosted: Thu 12 Nov '09 13:11    Post subject: Reply with quote

Thank you very much for your very fast answer Smile
I will try.
Back to top
Marge



Joined: 25 Aug 2009
Posts: 22

PostPosted: Mon 16 Nov '09 11:52    Post subject: Reply with quote

Hello again.
I installed a dummy server to test the configuration.
I removed the comment from
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
and
Include conf/extra/httpd-vhosts.conf
from httpd.conf
In httpd-vhosts.conf I have the following:

<VirtualHost *:80>
ServerAdmin webmaster@domain.com
DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs"
ServerName www.domain.com
ServerAlias www.domain.com
ErrorLog "logs/domain.com.localhost-error.log"
CustomLog "logs/domain.com.localhost-access.log" common
</VirtualHost>


<VirtualHost *:80>
ServerName test.domain.com

ProxyRequests off
ProxyPass / http://192.168.1.3/somefile.php
ProxyPassReverse / http://192.168.1.3/somefile.php
</VirtualHost>

but it seems that it does not work Sad
Main page works but not the reverse proxy Sad

#edit:
I changed

<VirtualHost *:80>
ServerName test.domain.com

ProxyRequests off
ProxyPass / http://192.168.1.3/somefile.php
ProxyPassReverse / http://192.168.1.3/somefile.php
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
</VirtualHost>

and it worked. I do not know how, but it worked. Now it's not working...

#edit2: Now it's working. The problem was the DNS.
Back to top
Marge



Joined: 25 Aug 2009
Posts: 22

PostPosted: Mon 16 Nov '09 14:21    Post subject: Reply with quote

The final configuration is:

<VirtualHost *:80>
ServerAdmin webmaster@domain.com
DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs"
ServerName domain.com
ServerAlias domain.com
ErrorLog "logs/domain.com.localhost-error.log"
CustomLog "logs/domain.com.localhost-access.log" common
</VirtualHost>


<VirtualHost *:80>
ServerName test.domain.com
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPreserveHost On
ProxyRequests off
ProxyPass / http://192.168.1.3/
ProxyPassReverse / http://192.168.1.3/
</VirtualHost>

I want to ask something else.
When I acces the server it appear something like:
test.domain.com/SomeDirectory/somefile.php
It is possible to hide "SomeDirectory/somefile.php" from the url in address bar and the address bar to look like test.domain.com???
The page redirected is only one page(one script), it does not have links to other pages...
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7355
Location: Germany, Next to Hamburg

PostPosted: Mon 16 Nov '09 15:20    Post subject: Reply with quote

Yes you can
-snip-
Code:

..
ProxyPass / http://192.168.1.3/SomeDirectory/
ProxyPassReverse / http://192.168.1.3/SomeDirectory/
..


Than you can rename that file to index.php or change the directory index on the second server to DirectoryIndex somefile.php index.php index.htm index.html
Back to top
Marge



Joined: 25 Aug 2009
Posts: 22

PostPosted: Tue 17 Nov '09 8:56    Post subject: Reply with quote

Thank you, I will try on the main server.
Back to top
Marge



Joined: 25 Aug 2009
Posts: 22

PostPosted: Thu 19 Nov '09 9:40    Post subject: Reply with quote

Works perfectly, and thank you again...
Now, maybe I should make other topic but since is almost the same, I'll write here.
Because all other applications are in form domain.com/application, I want to ask how to make something like:
domain.com/test

I have read This topic: http://www.apachelounge.com/viewtopic.php?t=1569
Can I use it (mod_proxy_html) ?
I must tell that there are other applications running on the 192.168.1.2 server in form of domain.com/app
If so, Where I put that script?
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7355
Location: Germany, Next to Hamburg

PostPosted: Thu 19 Nov '09 10:55    Post subject: Reply with quote

Well if the folder is on the same server you could use an alias.

example

Code:

Alias /test "c:/path/to/application"
<Directory "c:/path/to/application">
Order allow,deny
Allow from all
</Directory>


You need mod_proxy_html only when you have to correct paths in the html from the remote server in reverse proxy situation.
Back to top
Marge



Joined: 25 Aug 2009
Posts: 22

PostPosted: Sun 22 Nov '09 9:59    Post subject: Reply with quote

No, it's not, I want to use it in the same way that I described earlier.

But instead of subdomain.domain.com, to use domain.com/subdomain
(because for now, all applications are of this form, but on the same server-except for this one) Can it be done?

I think that this could help me:
Code:
ProxyPass /app1/ http://internal1.example.com/
ProxyPass /app2/ http://internal2.example.com/
ProxyHTMLURLMap http://internal1.example.com /app1
ProxyHTMLURLMap http://internal2.example.com /app2


(from the link that I show earlier)
But where do I put that code? In httpd-vhosts.conf or httpd.conf ?
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7355
Location: Germany, Next to Hamburg

PostPosted: Sun 22 Nov '09 21:32    Post subject: Reply with quote

Marge wrote:

But where do I put that code? In httpd-vhosts.conf or httpd.conf ?


Put it where ever you like to put it. Don't forget to use the location stuff there, too.


Some example
Code:

ProxyPass /home http://192.168.178.21/home
ProxyPassReverse /home http://192.168.178.21/home
ProxyHTMLURLMap http://192.168.178.21/home /home

<Location /home>
ProxyPassReverse /home
   SetOutputFilter    proxy-html
   ProxyHTMLURLMap    /home   /
   RequestHeader     unset   Accept-Encoding
</Location>


You can read the whole stuff about it at the authors page from mod_proxy_html http://www.apachetutor.org/admin/reverseproxies
Back to top
Marge



Joined: 25 Aug 2009
Posts: 22

PostPosted: Tue 24 Nov '09 18:56    Post subject: Reply with quote

Thank you again Smile
Back to top
Marge



Joined: 25 Aug 2009
Posts: 22

PostPosted: Wed 25 Nov '09 13:34    Post subject: Reply with quote

Unfortunately, it does not work
I will come back to tell more.

Code:
ProxyRequests off
ProxyPass /text/ http://192.168.1.3/sosiri_txt
ProxyPass /grafic/ http://192.168.1.3/sosiri_graf
ProxyHTMLURLMap http://192.168.1.3/sosiri_txt /text
ProxyHTMLURLMap http://192.168.1.3/sosiri_graf /grafic

<Location /text/>
        ProxyPassReverse /
        ProxyHTMLEnable On
        ProxyHTMLURLMap  /      /text/
        RequestHeader    unset  Accept-Encoding
</Location>

<Location /grafic/>
        ProxyPassReverse /
        ProxyHTMLEnable On
        ProxyHTMLURLMap /       /grafic/
        RequestHeader   unset   Accept-Encoding
</Location>
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7355
Location: Germany, Next to Hamburg

PostPosted: Wed 25 Nov '09 17:40    Post subject: Reply with quote

In my example it was different

you have

Code:

proxyHTMLURLMap  /      /text/
and
ProxyHTMLURLMap /       /grafic/

but it should be
Code:

proxyHTMLURLMap  /text/       /
and
ProxyHTMLURLMap /grafic/        /
Back to top
Marge



Joined: 25 Aug 2009
Posts: 22

PostPosted: Sun 29 Nov '09 14:12    Post subject: Reply with quote

I tryed your suggestion, this was after that.
It seems that the apache server is no longer starting after I inserted that.
Even if I modify with the last configuration (the one discussed and worked) I must restart the PC in order to be able to start the apache webserver.

I disabled virtualhosts, I put this in httpd.conf. Same thing
Maybe is because that I don't have

Code:
LoadFile   /usr/lib/libxml2.so
...
LoadModule xml2enc_module modules/mod_xml2enc.so

???
Back to top
glsmith
Moderator


Joined: 16 Oct 2007
Posts: 2268
Location: Sun Diego, USA

PostPosted: Sun 29 Nov '09 19:40    Post subject: Reply with quote

If you are using mod_proxy_html then I guess it would need libxml2.DLL looking at my build note for the beast.

If you drop that dll in your Apache's bin/ folder there is no need for the LoadFile line. It looks like the mod_proxy_html here in the downloads includes the mod_xml2enc.so and libxml2.dll .. and a config sample.
Back to top
Marge



Joined: 25 Aug 2009
Posts: 22

PostPosted: Sun 29 Nov '09 21:36    Post subject: Reply with quote

Thanks, I will try.
Back to top
Marge



Joined: 25 Aug 2009
Posts: 22

PostPosted: Thu 03 Dec '09 12:22    Post subject: Reply with quote

I put this in httpd.conf

Code:
ProxyRequests off
ProxyPass /text/ http://192.168.1.3/sosiri_txt
ProxyPass /grafic/ http://192.168.1.3/sosiri_graf
ProxyHTMLURLMap http://192.168.1.3/sosiri_txt /text
ProxyHTMLURLMap http://192.168.1.3/sosiri_graf /grafic

<Location /text/>
        ProxyPassReverse /
        ProxyHTMLEnable On
        ProxyHTMLURLMap  /text/       /
        RequestHeader    unset  Accept-Encoding
</Location>

<Location /grafic/>
        ProxyPassReverse /
        ProxyHTMLEnable On
        ProxyHTMLURLMap /grafic/        /
        RequestHeader   unset   Accept-Encoding
</Location>


Commented Include "conf/extra/httpd-vhosts.conf"
and added libxml2.DLL in /bin directory


Uncommented are:
Code:
Listen 80
ServerName *:80
DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs"
LoadModule actions_module modules/mod_actions.so
LoadModule alias_module modules/mod_alias.so
LoadModule asis_module modules/mod_asis.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule authn_default_module modules/mod_authn_default.so
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authz_default_module modules/mod_authz_default.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule cgi_module modules/mod_cgi.so
LoadModule dir_module modules/mod_dir.so
LoadModule env_module modules/mod_env.so
LoadModule headers_module modules/mod_headers.so
LoadModule include_module modules/mod_include.so
LoadModule isapi_module modules/mod_isapi.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule mime_module modules/mod_mime.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule setenvif_module modules/mod_setenvif.so
<FilesMatch "^\.ht">
  Order allow,deny
  Deny from all
  Satisfy All
</FilesMatch>
ErrorLog "logs/error.log"
LogLevel warn
DefaultType text/plain
<Directory "/">
Options FollowSymLinks
  Deny from all
  Order deny,allow
  AllowOverride None
</Directory>
 Options FollowSymLinks Indexes
Allow from all
Order allow,deny
  AllowOverride None
</Directory>
<Directory "C:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin">
  Options None
  Allow from all
  Order allow,deny
 AllowOverride None
</Directory>
<IfModule !mpm_netware_module>
  <IfModule !mpm_winnt_module>
    User daemon
    Group daemon
  </IfModule>
</IfModule>
<IfModule dir_module>
  DirectoryIndex index.php index.html
</IfModule>
<IfModule log_config_module>
  LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
  LogFormat "%h %l %u %t \"%r\" %>s %b" common
  CustomLog "logs/access.log" common
  <IfModule logio_module>
    # You need to enable mod_logio.c to use %I and %O
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
  </IfModule>
</IfModule>
<IfModule alias_module>
  ScriptAlias /cgi-bin/ "C:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin/"
</IfModule>
<IfModule cgid_module>
</IfModule>
<IfModule mime_module>
  TypesConfig "conf/mime.types"
  AddType application/x-compress .Z
  AddType application/x-gzip .gz .tgz
  AddType application/x-httpd-php .php
</IfModule>

<IfModule ssl_module>
  SSLRandomSeed startup builtin
  SSLRandomSeed connect builtin
</IfModule>


When I tryed to start the server, the error was: The requested operation has failed.
After I changed back, again, I had to reboot the pc to make apache to start.

I have 1 web server, 1 forum both with "/" ending
(domain.com/app)

Any help is appreciated Very Happy
Back to top
Marge



Joined: 25 Aug 2009
Posts: 22

PostPosted: Fri 04 Dec '09 21:46    Post subject: Reply with quote

I found the files, except for mod_xml2enc.so. But soon... I will post my results. (the mod_proxy_html is a demo Sad( )
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7355
Location: Germany, Next to Hamburg

PostPosted: Tue 08 Dec '09 11:30    Post subject: Reply with quote

I'm not an expert in reverse proxy, but AFAIK your block should look like

Code:

ProxyRequests off
ProxyPass /text/ http://192.168.1.3/sosiri_txt/
ProxyPass /grafic/ http://192.168.1.3/sosiri_graf/
<Location /text/>
   ProxyPassReverse /
   ProxyHTMLEnable On
   ProxyHTMLURLMap / /text/   
   RequestHeader    unset  Accept-Encoding
 </Location>
<Location /grafic/>
   ProxyPassReverse /
   ProxyHTMLEnable On
   ProxyHTMLURLMap / /grafic/
   RequestHeader    unset  Accept-Encoding 
 </Location>



hm, another way might be to have a windows share and the data with an alias over a UNC Drive. See http://www.apachelounge.com/viewtopic.php?t=3259
Back to top


Reply to topic   Topic: Two webservers (public and Internal) : A suggestion please View previous topic :: View next topic
Post new topic   Forum Index -> Apache Page 1, 2  Next