LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   General (https://www.linuxquestions.org/questions/general-10/)
-   -   Apache problem with proxy and reverseproxy (https://www.linuxquestions.org/questions/general-10/apache-problem-with-proxy-and-reverseproxy-895242/)

bathory 09-01-2011 08:33 AM

Hi,

Quote:

RewriteCond %{HTTP} ^on$
The above is wrong. There is no such variable. I guess that's why rewrite is not working
Also, better use:
Code:

RewriteCond %{REQUEST_URI} ^/123(.*)$
to take care of the trailing slash "/"
And I don't understand the last rewrite rule after the proxy stuff.
Quote:

RewriteRule ^/123/(.*) http://192.0.1.1:88/ap/ [L,R]
After fixing the url with mod_rewrite, the proxy should take control for the rest.

Regards

sameone 09-02-2011 02:16 AM

2 Attachment(s)
Now is my configuration like this:


My proxy: 192.0.0.0 (DMZ)

My httpd.conf


AddDefaultCharset utf-8

RewriteEngine On

Options +FollowSymlinks



RewriteCond %{REQUEST_URI} ^/123/(.*)$

RewriteCond %{REQUEST_URI} !^/123/f$

RewriteRule (.*) /123/f?p=100:1 [R]



ProxyRequests Off

ProxyPass /123/ http://192.0.1.1:88/ap/

ProxyPassReverse /123/ http://192.0.1.1:88/ap/



Now i think that this RewriteCond works, but there is still a problem.


1.

When I write URL - proxy - https://192.0.0.0/123/ I become http://192.0.1.1:88/ap/ (my administrator console) -
But I wont this URL -> https://192.0.1.1:88/ap/f?p=100:1

It's look that here, where is https, RewriteCond does not work. What to change ??

My proxy has to work with https.


2.

When I write URL - proxy - http://192.0.0.0/123/ I become the right URL -> https://192.0.1.1:88/ap/f?p=100:1

But there is a problem

2.1

I become login, but it looks that something did not go true proxy.

Picture 1 - the login page when she came true proxy.
Picture 2 - the login page from application

Where is here problem.


Thanks for your time

bathory 09-02-2011 03:02 AM

Quote:

When I write URL - proxy - https://192.0.0.0/123/ I become http://192.0.1.1:88/ap/ (my administrator console) -
But I wont this URL -> https://192.0.1.1:88/ap/f?p=100:1

It's look that here, where is https, RewriteCond does not work. What to change ??
I don't understand what you mean. If a request is done through https then it cannot be turned in http without a rewrite action from you, that is not happening here!
Anyway, why don't you use https in the proxied url?

Quote:

When I write URL - proxy - http://192.0.0.0/123/ I become the right URL -> https://192.0.1.1:88/ap/f?p=100:1
I've already told you to remove the trailing slash exactly for this reason

Quote:

I become login, but it looks that something did not go true proxy.
Huh, maybe you need ProxyPreserveHost On. This depends mostly on the backend application.

You may try this:
Code:

RewriteCond %{REQUEST_URI} ^/123(.*)$
RewriteCond %{REQUEST_URI} !^/123/f$
RewriteRule (.*) /123/f?p=100:1 [R]

ProxyPreserveHost On
ProxyRequests Off
ProxyPass /123/ https://192.0.1.1:88/ap/
ProxyPassReverse /123/ https://192.0.1.1:88/ap/


sameone 09-02-2011 03:58 AM

Quote:

why don't you use https in the proxied url?
Because application does not work on https


Quote:

When I write URL - proxy - http://192.0.0.0/123/ I become the right URL -> http://192.0.1.1:88/ap/f?p=100:1
I've already told you to remove the trailing slash exactly for this reason
Where I have to remove slash ??

sameone 09-02-2011 04:11 AM

LOGS


Proxy_ssl error

[Fri Sep 02 10:30:13 2011] [debug] mod_proxy_http.c(56): proxy: HTTP: canonicalising URL //192.0.0.0:88/ap/f

[Fri Sep 02 10:30:13 2011] [debug] proxy_util.c(1489): [client 192.0.0.0] proxy: http: found worker http://192.0.1.1/ap/ for http://192.0.1.1:88/ap/f?p=100:1, referer: http://192.0.1.1/123/f?p=100:1

[Fri Sep 02 10:30:13 2011] [debug] mod_proxy.c(988): Running scheme http handler (attempt 0)

[Fri Sep 02 10:30:13 2011] [debug] mod_proxy_http.c(1924): proxy: HTTP: serving URL http://192.0.1.1:88/ap/f?p=100:1

[Fri Sep 02 10:30:13 2011] [debug] proxy_util.c(2045): proxy: HTTP: has acquired connection for (192.0.0.1)

[Fri Sep 02 10:30:13 2011] [debug] proxy_util.c(2103): proxy: connecting http://192.0.1.1:88/ap/f?p=100:1 to 192.0.1.1:88

[Fri Sep 02 10:30:13 2011] [debug] proxy_util.c(2201): proxy: connected /ap/f?p=100:1 to 192.0.1.1:88

[Fri Sep 02 10:30:13 2011] [debug] proxy_util.c(2356): proxy: HTTP: fam 2 socket created to connect to 192.0.1.1

[Fri Sep 02 10:30:13 2011] [debug] proxy_util.c(2468): proxy: HTTP: connection complete to 192.0.1.1:88 (192.0.1.1)

[Fri Sep 02 10:30:13 2011] [debug] mod_proxy_http.c(1701): proxy: start body send

[Fri Sep 02 10:30:13 2011] [info] [client 192.0.0.0] (32)Broken pipe: core_output_filter: writing data to the network

[Fri Sep 02 10:30:13 2011] [debug] mod_proxy_http.c(1790): proxy: end body send

[Fri Sep 02 10:30:13 2011] [debug] proxy_util.c(2063): proxy: HTTP: has released connection for (192.0.1.1)

[Fri Sep 02 10:30:13 2011] [info] [client 192.0.0.0] (32)Broken pipe: core_output_filter: writing data to the network


Rewrite log


192.0.0.0 - - init rewrite engine with requested uri /

(3) applying pattern '(.*)' to uri '/'


init rewrite engine with requested uri /error/HTTP_FORBIDDEN.html.var

applying pattern '(.*)' to uri '/error/HTTP_FORBIDDEN.html.var'

RewriteCond: input='/error/HTTP_FORBIDDEN.html.var' pattern='^/123/(.*)$' => not-matched

(1) pass through /error/HTTP_FORBIDDEN.html.var





init rewrite engine with requested uri /123/

applying pattern '(.*)' to uri '/123/'

RewriteCond: input='/123/' pattern='^/123/(.*)$' => matched

RewriteCond: input='/123/' pattern='!^/123/f$' => matched

rewrite '/123/' -> '/123/f?p=100:1'

split uri=/123/f?p=100:1 -> uri=/123/f, args=p=100:1

explicitly forcing redirect with http://192.0.0.0/123/f

http://192.0.0.0/alis/f for redirect

redirect to http://192.0.0.0/123/f?p=1000:1 [REDIRECT/302]
RewriteCond: input='/i/themes/theme_2/theme_3_1.css' pattern='^/123/(.*)$' => not-matched




(2) init rewrite engine with requested uri /error/contact.html.var

(1) pass through /error/contact.html.var

(2) init rewrite engine with requested uri /123/f

(3) applying pattern '(.*)' to uri '/123/f'

(4) RewriteCond: input='/123/f' pattern='^/123/(.*)$' => matched

(4) RewriteCond: input='/123/f' pattern='!^/123/f$' => not-matched

(1) pass through /123/f

bathory 09-02-2011 05:00 AM

Quote:

Originally Posted by sameone (Post 4459473)
Because application does not work on https




Where I have to remove slash ??

How comes it doesn't work on https when you say
Quote:

But I wont this URL -> https://192.0.1.1:88/ap/f?p=100:1
If you want the initial request to be in https then before the other rewrite stuff, add:
Code:

RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}

About the trailing slash. Remove this (in red):
Code:

RewriteCond %{REQUEST_URI} ^/123/(.*)$
I hope that it's clear now!

sameone 09-02-2011 05:56 AM

Quote:

How comes it doesn't work on https when you say
Quote:
But I wont this URL -> https://192.0.1.1:88/ap/f?p=100:1

My mistake when writting - -> http://192.0.1.1:88/ap/f?p=100:1


Quote:

RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}
Ok this work and convert http to https



Quote:

RewriteCond %{REQUEST_URI} ^/123/(.*)$
That only means url with http://192.0.0.0/123/ or without http://192.0.0.0/123


Any idea about problem


I canlogin, but it looks that something did not go true proxy.

Picture 1 - the login page when she came true proxy.
Picture 2 - the login page from application

Where is here problem.

bathory 09-02-2011 06:50 AM

Quote:

RewriteCond %{REQUEST_URI} ^/123/(.*)$
That only means url with http://192.0.0.0/123/ or without http://192.0.0.0/123
If you want both (with or without the /) to work, use my rewrite rule: REMOVE THE SLASH!!!
You should read mod_rewrite documentation and especially the use of regexes.

Quote:

I canlogin, but it looks that something did not go true proxy.
So, anything else works except the images in the login page?
Check the logs in both apache and the backend server and see why is this happening.

sameone 09-02-2011 07:00 AM

Quote:

So, anything else works except the images in the login page?
If It was so, then would be OK. I only become the login page. But login does not work. No response from button (LOGIN) and so on.

It looks that I only become true proxy html page, without connection ...



Quote:

Check the logs in both apache and the backend server and see why is this happening.
I send you my log. Did you find something ...

sameone 10-10-2011 04:38 AM

Have anyone Idea how to set sercured proxy server ??


Please help


All times are GMT -5. The time now is 05:00 PM.