You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Steven Shi <st...@gmail.com> on 2015/08/25 05:30:18 UTC

[users@httpd] Proxying From Directory To App On Port

I'm trying to proxy /app to localhost:2000 (where the app is hosted).
Unfortunately, whenever the app makes a GET/POST request, the port 2000 is
lost and the request is made to localhost:80 rather than localhost:2000.

I feel as if the solution is something simple but I haven't been able to
discover it from three days of trial and error.

Re: [users@httpd] Re: Proxying From Directory To App On Port

Posted by Steven Shi <st...@gmail.com>.
I'll try to clearly state what I did.

When you said "Your Apache config proxies the URI prefix
"/projects/CS32Brewer/".
Is that the URI prefix your browser client code is using?", it occurred to
me that if the Host was anchored to "localhost:80" and couldn't be changed
to "localhost:2000", I could try to proxy the requests themselves.
Disclaimer*: I don't know if this logic of thinking was entirely correct.

My thinking was that if a request for "/projects/CS32Brewer/" results in
"localhost:2000", then wouldn't a request for "/projects/CS32Brewer/request"
result in "localhost:2000/request"?

Therefore I changed all the absolute path requests from "/request" (which
would result in "localhost:80/request") to "./request" which takes the
parent directory (in this case "/projects/CS32Brewer/") and appends the
request to that parent directory.

It turns out the request itself proxies.

The weirdest thing is that I removed proxypassreverse as well as the
proxy_html module.

All I have in place is proxypass "/projects/CS32Brewer/" "
http://localhost:2000".

The second weird thing I was not expecting was that my SSL problem was
suddenly corrected as well.  I originally had a solution this morning that
used absolute pathing for the requests ("/request" would be "
http://localhost:2000/request") but this turned out to be a bit of work to
maintain in whenever I moved anything around / changed ports etc; it also
did not work over SSL and complained about insecure requests to an http
site.  Somehow, using the relative pathing from the parent directory killed
two birds with one stone while being extremely flexible.

I do not currently have my configuration page but would be happy to share
it if it clarifies things.  I'm quite befuddled by the results myself.
Please let me know any further clarifications I can make.

Last thing to note: I tested this configuration with a second project that
has the same build and it works perfectly fine over SSL as well.

On Fri, Aug 28, 2015 at 12:23 AM, Kurtis Rader <kr...@skepticism.us> wrote:

> On Thu, Aug 27, 2015 at 8:21 PM, Steven Shi <st...@gmail.com>
> wrote:
>
>> Hey Kurtis,
>>
>> I was in the middle of replying and then something clicked for me.  I
>> spent the day today working on this one more time and ended up getting it
>> working.  I believe my fundamental understanding of a proxy was simply
>> incorrect.
>>
>
>> Your comment about the URI prefix was what made it click for me.
>>
>
> I am happy you solved your problem but am concerned you still do not
> really understand what is happening.
>
>
>> Basically all my requests on the client front end were formatted like so
>> "/command".  I mistakenly thought that the client would run these with
>> respect to the host it came from (Jetty returns the client as a result of
>> the initial proxied GET to localhost:2000).  Apparently, the client ends up
>> realizing it is no longer on localhost:2000 but is now instead on
>> localhost:80 and was calling the requests as such.  This would also make
>> sense why "/command" would result in the GET/POST URL as
>> "localhost:80/command".
>>
>
> The client code running in the browser does not "realize" it is no longer
> on localhost:2000.  At least not in the sense you seem to mean. The browser
> client code is simply going (that is, making requests) where it was told to
> go. Specifically, it appears (as I suspected) your Jetty backend has no
> knowledge it is being proxied and is returning a response containing URIs
> that implied the Jetty backend could be directly reached on port 80
> (because the URIs in its response do not include a port number). When in
> fact it can only be directly reached on port 2000. This is a very common
> problem and why the ProxyReversePass directive in conjunction with
> the proxy_html_module (or other suitable module) exists.
>
> After your comment, I realized that requests also need to have the URI
>> with respect to the original host rather than the proxy on localhost:2000.
>> As such I changed every instance of "/command" to "./command" and now
>> everything works perfectly.
>>
>
> I don't understand what you did. For the benefit of myself, and everyone
> else reading this email thread, can you provide more detail regarding what
> your changed?
>
>
>> I did in fact enable the high levels of debug output and could make no
>> sense of them unfortunately...somehow one request ended up in 200 lines of
>> garble (I cleared the log beforehand).
>>
>
> That is often the case. Which is why it is important to perform one
> experiment at a time; i.e., issuing one client request then saving the log
> files for analysis. If you do not minimize the number of variables (e.g.,
> the number of unrelated HTTP requests) it can be very difficult to derive
> any conclusions from the data.
>
> --
> Kurtis Rader
> Caretaker of the exceptional canines Junior and Hank
>

Re: [users@httpd] Re: Proxying From Directory To App On Port

Posted by Kurtis Rader <kr...@skepticism.us>.
On Thu, Aug 27, 2015 at 8:21 PM, Steven Shi <st...@gmail.com> wrote:

> Hey Kurtis,
>
> I was in the middle of replying and then something clicked for me.  I
> spent the day today working on this one more time and ended up getting it
> working.  I believe my fundamental understanding of a proxy was simply
> incorrect.
>

> Your comment about the URI prefix was what made it click for me.
>

I am happy you solved your problem but am concerned you still do not really
understand what is happening.


> Basically all my requests on the client front end were formatted like so
> "/command".  I mistakenly thought that the client would run these with
> respect to the host it came from (Jetty returns the client as a result of
> the initial proxied GET to localhost:2000).  Apparently, the client ends up
> realizing it is no longer on localhost:2000 but is now instead on
> localhost:80 and was calling the requests as such.  This would also make
> sense why "/command" would result in the GET/POST URL as
> "localhost:80/command".
>

The client code running in the browser does not "realize" it is no longer
on localhost:2000.  At least not in the sense you seem to mean. The browser
client code is simply going (that is, making requests) where it was told to
go. Specifically, it appears (as I suspected) your Jetty backend has no
knowledge it is being proxied and is returning a response containing URIs
that implied the Jetty backend could be directly reached on port 80
(because the URIs in its response do not include a port number). When in
fact it can only be directly reached on port 2000. This is a very common
problem and why the ProxyReversePass directive in conjunction with
the proxy_html_module (or other suitable module) exists.

After your comment, I realized that requests also need to have the URI with
> respect to the original host rather than the proxy on localhost:2000.  As
> such I changed every instance of "/command" to "./command" and now
> everything works perfectly.
>

I don't understand what you did. For the benefit of myself, and everyone
else reading this email thread, can you provide more detail regarding what
your changed?


> I did in fact enable the high levels of debug output and could make no
> sense of them unfortunately...somehow one request ended up in 200 lines of
> garble (I cleared the log beforehand).
>

That is often the case. Which is why it is important to perform one
experiment at a time; i.e., issuing one client request then saving the log
files for analysis. If you do not minimize the number of variables (e.g.,
the number of unrelated HTTP requests) it can be very difficult to derive
any conclusions from the data.

-- 
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank

Re: [users@httpd] Re: Proxying From Directory To App On Port

Posted by Steven Shi <st...@gmail.com>.
Hey Kurtis,

I was in the middle of replying and then something clicked for me.  I spent
the day today working on this one more time and ended up getting it
working.  I believe my fundamental understanding of a proxy was simply
incorrect.

Your comment about the URI prefix was what made it click for me.

Basically all my requests on the client front end were formatted like so
"/command".  I mistakenly thought that the client would run these with
respect to the host it came from (Jetty returns the client as a result of
the initial proxied GET to localhost:2000).  Apparently, the client ends up
realizing it is no longer on localhost:2000 but is now instead on
localhost:80 and was calling the requests as such.  This would also make
sense why "/command" would result in the GET/POST URL as
"localhost:80/command".

After your comment, I realized that requests also need to have the URI with
respect to the original host rather than the proxy on localhost:2000.  As
such I changed every instance of "/command" to "./command" and now
everything works perfectly.

I did in fact enable the high levels of debug output and could make no
sense of them unfortunately...somehow one request ended up in 200 lines of
garble (I cleared the log beforehand).

Anyways, I was wrong in thinking that the proxy worked with localhost:2000
as if it were inside a box and simply gave inputs and took outputs.  It
seems that the proxy directly serves the client to the original URL of
/projects/CS32Brewer...

I was afraid that I'd have to configure the SSL as well given that I
previously had complaints from the server of insecure requests to http;
fortunately, something just clicked and it works fine....

Thank you for all your help and patience, let me know if you'd like any
more details.  I apologize for my vagueness and ambiguity so thank you for
sticking with me on it.


On Thu, Aug 27, 2015 at 12:12 AM, Kurtis Rader <kr...@skepticism.us> wrote:

> On Tue, Aug 25, 2015 at 10:25 PM, Steven Shi <st...@gmail.com>
> wrote:
>
>> The "app" consists of a maven built java back-end which utilizes the
>> maven build of apache spark ("http://sparkjava.com/").  To my
>> understanding, the spark API initiates a Jetty server which listens on a
>> specified port for GET / POST requests.  It then either processes the data
>> sent in a POST request or simply returns the html/css/js page for a GET
>> request.
>>
>
> You really need to stop using the term "app" for every piece of software
> involved in this problem. You've used "app" to refer to the jQuery client
> front end and the Java backend and possibly the Apache HTTP middle layer.
> Not to mention the URI prefix being proxied.
>
>
>> When I said "the port 2000 is lost", I meant that if I go in to the app
>> through the proxy /app and attempt to issue GET / POST commands via the
>> jQuery front end interface, google's developer console shows the remote
>> address as my_ip:(80, 443) and the request URL is simply
>> my_hostname/command.  Likewise, the origin and the host are incorrect.
>>
>
> I can't tell from the Chrome developer console snapshot if the "POST
> https://stevenshi.me/run" request that failed with a 404 status was due
> to a redirect or if it was the original request made by the browser client
> code. If it was the original request then something is wrong in how you
> have told the client code which URI to use. If it was due to a redirect the
> question becomes whether the redirect is from Apache or your Spark backend.
>
> I'm willing to bet the problem is the Spark backend is issuing a HTTP
> redirect that leads to the Apache middle layer no knowing how to handle the
> subsequent request. The solution might be as simple as enabling rewriting
> of proxied HTML with this directive in your virtual host:
>
> ProxyHTMLEnable On
>
> That will require an appropriate "LoadModule proxy_html_module" in your
> Apache config.
>
> Your Apache config proxies the URI prefix "/projects/CS32Brewer/". Is
> that the URI prefix your browser client code is using? Does the Apache
> access log show requests from the browser with the URI prefix? Have you
> enabled higher levels of debug output from Apache as I suggested? If so
> what does the Apache error log show for a failing request?
>
>
>> If HTTP_HOST is the "Host:" shown in google dev console "Request
>> Headers", the app is not setting it correctly on /app (it is "my_hostname"
>> rather than "my_hostname:2000").
>> If HTTP_HOST is not what's said above, then how do I check what it is?
>>
>
> What do you mean by "correctly on /app"? Nowhere in the data you've
> provided so far, in particular the Apache virtual host configuration, is a
> URI prefix of "/app" referenced. If you're using that as a synonym for
> "/projects/CS32Brewer" please say so.
>
> --
> Kurtis Rader
> Caretaker of the exceptional canines Junior and Hank
>

Re: [users@httpd] Re: Proxying From Directory To App On Port

Posted by Kurtis Rader <kr...@skepticism.us>.
On Tue, Aug 25, 2015 at 10:25 PM, Steven Shi <st...@gmail.com> wrote:

> The "app" consists of a maven built java back-end which utilizes the maven
> build of apache spark ("http://sparkjava.com/").  To my understanding,
> the spark API initiates a Jetty server which listens on a specified port
> for GET / POST requests.  It then either processes the data sent in a POST
> request or simply returns the html/css/js page for a GET request.
>

You really need to stop using the term "app" for every piece of software
involved in this problem. You've used "app" to refer to the jQuery client
front end and the Java backend and possibly the Apache HTTP middle layer.
Not to mention the URI prefix being proxied.


> When I said "the port 2000 is lost", I meant that if I go in to the app
> through the proxy /app and attempt to issue GET / POST commands via the
> jQuery front end interface, google's developer console shows the remote
> address as my_ip:(80, 443) and the request URL is simply
> my_hostname/command.  Likewise, the origin and the host are incorrect.
>

I can't tell from the Chrome developer console snapshot if the "POST
https://stevenshi.me/run" request that failed with a 404 status was due to
a redirect or if it was the original request made by the browser client
code. If it was the original request then something is wrong in how you
have told the client code which URI to use. If it was due to a redirect the
question becomes whether the redirect is from Apache or your Spark backend.

I'm willing to bet the problem is the Spark backend is issuing a HTTP
redirect that leads to the Apache middle layer no knowing how to handle the
subsequent request. The solution might be as simple as enabling rewriting
of proxied HTML with this directive in your virtual host:

ProxyHTMLEnable On

That will require an appropriate "LoadModule proxy_html_module" in your
Apache config.

Your Apache config proxies the URI prefix "/projects/CS32Brewer/". Is that
the URI prefix your browser client code is using? Does the Apache access
log show requests from the browser with the URI prefix? Have you enabled
higher levels of debug output from Apache as I suggested? If so what does
the Apache error log show for a failing request?


> If HTTP_HOST is the "Host:" shown in google dev console "Request Headers",
> the app is not setting it correctly on /app (it is "my_hostname" rather
> than "my_hostname:2000").
> If HTTP_HOST is not what's said above, then how do I check what it is?
>

What do you mean by "correctly on /app"? Nowhere in the data you've
provided so far, in particular the Apache virtual host configuration, is a
URI prefix of "/app" referenced. If you're using that as a synonym for
"/projects/CS32Brewer" please say so.

-- 
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank

Re: [users@httpd] Re: Proxying From Directory To App On Port

Posted by Steven Shi <st...@gmail.com>.
I apologize for my vagueness.

The "app" consists of a maven built java back-end which utilizes the maven
build of apache spark ("http://sparkjava.com/").  To my understanding, the
spark API initiates a Jetty server which listens on a specified port for
GET / POST requests.  It then either processes the data sent in a POST
request or simply returns the html/css/js page for a GET request.

When I said "the port 2000 is lost", I meant that if I go in to the app
through the proxy /app and attempt to issue GET / POST commands via the
jQuery front end interface, google's developer console shows the remote
address as my_ip:(80, 443) and the request URL is simply
my_hostname/command.  Likewise, the origin and the host are incorrect.

[image: Inline image 2]


The correct request arguments in the working app on the port are shown below
[image: Inline image 3]


I do have virtual hosts defined in the Apache Server


>> <VirtualHost *:80>
>
>
>>         RewriteEngine on
>
>         RewriteCond %{SERVER_PORT} !^443$
>
>         RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R=301,L]
>
>
>>         ServerAdmin admin@stevenshi.me
>
>         ServerName stevenshi.me
>
>         ServerAlias www.stevenshi.me
>
>         DocumentRoot /var/www/html
>
>
>>         ErrorLog ${APACHE_LOG_DIR}/error.log
>
>         CustomLog ${APACHE_LOG_DIR}/access.log combined
>
>
>> </VirtualHost>
>
>
>>
>> <IfModule mod_ssl.c>
>
>         <VirtualHost *:443>
>
>                 ServerAdmin admin@stevenshi.me
>
>                 ServerName stevenshi.me:443
>
>                 ServerAlias www.stevenshi.me
>
>                 DocumentRoot /var/www/html
>
>
>>                 SSLProxyEngine on
>
>                 SSLEngine on
>
>                 SSLProtocol all -SSLv2
>
>                 SSLCipherSuite
>> ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM
>
>
>>                 SSLCertificateFile /etc/apache2/ssl/ssl.crt
>
>                 SSLCertificateKeyFile /etc/apache2/ssl/private.key
>
>                 SSLCertificateChainFile
>> /etc/apache2/ssl/sub.class1.server.ca.pem
>
>
>>                 ProxyRequests on
>
>                 ProxyPreserveHost on
>
>                 <Proxy *>
>
>                         Order deny,allow
>
>                         Allow from localhost
>
>                 </Proxy>
>
>
>>                 ProxyPass /projects/CS32Brewer/ http://localhost:2000/
>
>                 ProxyPassReverse /projects/CS32Brewer/
>> http://localhost:2000/
>
>                 #ProxyPassReverse /projects/CS32Brewer/
>> http://localhost:2000/
>
>
>>                 #ProxyPass /projects/Maps http://locahost:2001
>
>                 #ProxyPassReverse /projects/Maps http://localhost:2001
>
>
>>                 ErrorLog ${APACHE_LOG_DIR}/error.log
>
>                 CustomLog ${APACHE_LOG_DIR}/access.log combined
>
>         </VirtualHost>
>
> </IfModule>
>
>
>
If HTTP_HOST is the "Host:" shown in google dev console "Request Headers",
the app is not setting it correctly on /app (it is "my_hostname" rather
than "my_hostname:2000").
If HTTP_HOST is not what's said above, then how do I check what it is?

Thank you Kurtis!

On Wed, Aug 26, 2015 at 12:27 AM, Kurtis Rader <kr...@skepticism.us> wrote:

> On Tue, Aug 25, 2015 at 3:46 PM, Steven Shi <st...@gmail.com>
> wrote:
>
>> yes, they are both located on port 2000. I am indeed using the reverse
>> proxy option.
>>
>
>  On Tue, Aug 25, 2015 at 5:13 PM, Robert Webb <rw...@ropeguru.com> wrote:
>
>> Some clarification needed here.
>>>
>>> Is the app and the jetty backend on the same server? If so, are you
>>> using the reverse proxy option because jetty typically would listen on port
>>> 80 and is on a different server from the app but you have a need for app
>>> and jetty on the same server so the jetty needed an alternate port?
>>
>>
> We seem to have a language barrier. Robert was asking if you were using
> port 2000 for the Jetty server because it and the Apache web server were
> running on the same system. The only way they could "both [be] located on
> port 2000" is if they were running on different systems. You can't have two
> programs listening on the same TCP/IP port number.
>
> Your private email to me makes it clear that you have an Apache http
> server handling requests on port 80 and and a Jetty http server handling
> requests on port 2000. Both servers are running on the same system. The
> "app" is using the jQuery JavaScript library to handle HTTP requests.
> Whether or not the jQuery code is running in a browser controlled by a
> human is probably irrelevant. Nonetheless it might be helpful to know if
> the "app" is in fact browser side client code or something else.
>
> Back to your original problem statement:
>
> "Unfortunately, whenever the app makes a GET/POST request, the port 2000
>> is lost and the request is made to localhost:80 rather than localhost:2000."
>
>
> So we now know that "the app" is a jQuery program issuing a HTTP request
> with a URI like "/app/something" to the Apache httpd server on port 80. The
> Apache httpd server should be proxying the request to the Jetty server on
> port 2000 on the same system minus the "/app" URI prefix but is not doing
> so.
>
> What do you mean by "the port 2000 is lost"? What data leads you to
> believe the Apache httpd server is not proxying the request?
>
> Do you have virtual hosts defined in the Apache httpd server? If so have
> you confirmed "the app" is setting the HTTP_HOST header correctly?
>
> When I'm baffled by the behavior of my Apache httpd server I enable
> additional diagnostic output. For example,
>
> LoadModule dumpio_module libexec/apache2/mod_dumpio.so
> LogLevel trace6
> DumpIOInput On
> DumpIOOutput On
> LogLevel dumpio_module:trace7
>
>
> I then issue a series of carefully constructed HTTP requests meant to
> eliminate irrelevant details and examine the error log for clues.
>
> --
> Kurtis Rader
> Caretaker of the exceptional canines Junior and Hank
>

Re: [users@httpd] Re: Proxying From Directory To App On Port

Posted by Kurtis Rader <kr...@skepticism.us>.
On Tue, Aug 25, 2015 at 3:46 PM, Steven Shi <st...@gmail.com> wrote:

> yes, they are both located on port 2000. I am indeed using the reverse
> proxy option.
>

 On Tue, Aug 25, 2015 at 5:13 PM, Robert Webb <rw...@ropeguru.com> wrote:

> Some clarification needed here.
>>
>> Is the app and the jetty backend on the same server? If so, are you using
>> the reverse proxy option because jetty typically would listen on port 80
>> and is on a different server from the app but you have a need for app and
>> jetty on the same server so the jetty needed an alternate port?
>
>
We seem to have a language barrier. Robert was asking if you were using
port 2000 for the Jetty server because it and the Apache web server were
running on the same system. The only way they could "both [be] located on
port 2000" is if they were running on different systems. You can't have two
programs listening on the same TCP/IP port number.

Your private email to me makes it clear that you have an Apache http server
handling requests on port 80 and and a Jetty http server handling requests
on port 2000. Both servers are running on the same system. The "app" is
using the jQuery JavaScript library to handle HTTP requests. Whether or not
the jQuery code is running in a browser controlled by a human is probably
irrelevant. Nonetheless it might be helpful to know if the "app" is in fact
browser side client code or something else.

Back to your original problem statement:

"Unfortunately, whenever the app makes a GET/POST request, the port 2000 is
> lost and the request is made to localhost:80 rather than localhost:2000."


So we now know that "the app" is a jQuery program issuing a HTTP request
with a URI like "/app/something" to the Apache httpd server on port 80. The
Apache httpd server should be proxying the request to the Jetty server on
port 2000 on the same system minus the "/app" URI prefix but is not doing
so.

What do you mean by "the port 2000 is lost"? What data leads you to believe
the Apache httpd server is not proxying the request?

Do you have virtual hosts defined in the Apache httpd server? If so have
you confirmed "the app" is setting the HTTP_HOST header correctly?

When I'm baffled by the behavior of my Apache httpd server I enable
additional diagnostic output. For example,

LoadModule dumpio_module libexec/apache2/mod_dumpio.so
LogLevel trace6
DumpIOInput On
DumpIOOutput On
LogLevel dumpio_module:trace7


I then issue a series of carefully constructed HTTP requests meant to
eliminate irrelevant details and examine the error log for clues.

-- 
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank

Re: [users@httpd] Re: Proxying From Directory To App On Port

Posted by Steven Shi <st...@gmail.com>.
yes, they are both located on port 2000. I am indeed using the reverse
proxy option.

On Tue, Aug 25, 2015 at 5:13 PM, Robert Webb <rw...@ropeguru.com> wrote:

> Some clarification needed here.
>
> Is the app and the jetty backend on the same server? If so, are you using
> the reverse proxy option because jetty typically would listen on port 80
> and is on a different server from the app but you have a need for app and
> jetty on the same server so the jetty needed an alternate port?
>
> Robert
>
>
>
> On Tue, 25 Aug 2015 13:52:07 -0400
>
>  Steven Shi <st...@gmail.com> wrote:
>
>> My webserver is not listening on port 2000, the Jetty back end server of
>> the app is. The app is a maven build of apache spark which runs the Jetty
>> server; I have it set to listen on port 2000.
>>
>> The app in "any requests the app makes" would be the frontend of the
>> server
>> that uses jquery for requests.
>>
>> The remote IP as shown from the developers console in Google chrome. I
>> looked at the failed GET request.
>>
>> I know the problem is not caused by the SSL rewrite (tested by turning of
>> SSL module).
>>
>> On Tue, Aug 25, 2015 at 1:28 AM, Kurtis Rader <kr...@skepticism.us>
>> wrote:
>>
>> On Mon, Aug 24, 2015 at 9:52 PM, Steven Shi <st...@gmail.com>
>>> wrote:
>>>
>>> I have looked at and tried using the ProxyPassReverse directive.
>>>>
>>>> So the app communicates with the back end over port 2000.  Any requests
>>>> the app makes are sent to localhost:2000/foo to be processed by the back
>>>> end.
>>>>
>>>> Currently the relevant configuration is
>>>>
>>>> ProxyPass /app http://localhost:2000
>>>> ProxyPassReverse /app http://localhost:2000
>>>>
>>>> Basically, when the frontend of the app at localhost:2000 sends a GET
>>>> request, it's being sent as localhost:80/request rather than
>>>> localhost:2000/request.  Likewise, the remote IP address is shown as
>>>> localhost:80 rather than localhost:2000.
>>>>
>>>> If I go straight to localhost:2000, the app works as intended and makes
>>>> all requests to localhost:2000/request while showing the remote IP to be
>>>> localhost:2000.
>>>>
>>>>
>>> I can appreciate that you are frustrated by seemingly non-sensical
>>> behavior from the programs you're working with. I recently experienced a
>>> similar situation when trying to setup a virtual host that would proxy
>>> requests to another http server while the Apache httpd daemon also
>>> honored
>>> my mod_rewrite rules for blacklisted sources which should not be proxied.
>>> It took me several hours to figure out how to configure Apache httpd to
>>> do
>>> what I wanted. Nonetheless, your description of the situation is
>>> incoherent.
>>>
>>> Let us start with your last paragraph where you say "If I go straight to
>>> localhost:2000". I assume you are saying that if you enter "
>>> http://localhost:2000/" in your web browser you get the expected
>>> behavior. Is your Apache web server listening on port 2000? The reason I
>>> ask that question is due to your statement that "any requests the app
>>> makes
>>> are sent to localhost:2000". Which implies the app in question is
>>> directly
>>> connecting to the backend without being proxied by the Apache httpd
>>> process. What is this "app" and is it connecting to port 2000 or port 80
>>> on
>>> the local host?
>>>
>>> What is the "app" in the statement "any requests the app makes"? Is it a
>>> web browser or something else? And if something else please provide more
>>> details. What do you mean by "the remote IP address is shown as
>>> localhost:80"? Shown where? By what program?
>>>
>>> --
>>> Kurtis Rader
>>> Caretaker of the exceptional canines Junior and Hank
>>>
>>>
>
>

Re: [users@httpd] Re: Proxying From Directory To App On Port

Posted by Robert Webb <rw...@ropeguru.com>.
Some clarification needed here.

Is the app and the jetty backend on the same server? If so, are you using 
the reverse proxy option because jetty typically would listen on port 80 and 
is on a different server from the app but you have a need for app and jetty 
on the same server so the jetty needed an alternate port?

Robert



On Tue, 25 Aug 2015 13:52:07 -0400
  Steven Shi <st...@gmail.com> wrote:
> My webserver is not listening on port 2000, the Jetty back end 
>server of
> the app is. The app is a maven build of apache spark which runs the 
>Jetty
> server; I have it set to listen on port 2000.
> 
> The app in "any requests the app makes" would be the frontend of the 
>server
> that uses jquery for requests.
> 
> The remote IP as shown from the developers console in Google chrome. 
>I
> looked at the failed GET request.
> 
> I know the problem is not caused by the SSL rewrite (tested by 
>turning of
> SSL module).
> 
> On Tue, Aug 25, 2015 at 1:28 AM, Kurtis Rader <kr...@skepticism.us> 
>wrote:
> 
>> On Mon, Aug 24, 2015 at 9:52 PM, Steven Shi <st...@gmail.com>
>> wrote:
>>
>>> I have looked at and tried using the ProxyPassReverse directive.
>>>
>>> So the app communicates with the back end over port 2000.  Any 
>>>requests
>>> the app makes are sent to localhost:2000/foo to be processed by the 
>>>back
>>> end.
>>>
>>> Currently the relevant configuration is
>>>
>>> ProxyPass /app http://localhost:2000
>>> ProxyPassReverse /app http://localhost:2000
>>>
>>> Basically, when the frontend of the app at localhost:2000 sends a 
>>>GET
>>> request, it's being sent as localhost:80/request rather than
>>> localhost:2000/request.  Likewise, the remote IP address is shown as
>>> localhost:80 rather than localhost:2000.
>>>
>>> If I go straight to localhost:2000, the app works as intended and 
>>>makes
>>> all requests to localhost:2000/request while showing the remote IP 
>>>to be
>>> localhost:2000.
>>>
>>
>> I can appreciate that you are frustrated by seemingly non-sensical
>> behavior from the programs you're working with. I recently 
>>experienced a
>> similar situation when trying to setup a virtual host that would 
>>proxy
>> requests to another http server while the Apache httpd daemon also 
>>honored
>> my mod_rewrite rules for blacklisted sources which should not be 
>>proxied.
>> It took me several hours to figure out how to configure Apache httpd 
>>to do
>> what I wanted. Nonetheless, your description of the situation is 
>>incoherent.
>>
>> Let us start with your last paragraph where you say "If I go 
>>straight to
>> localhost:2000". I assume you are saying that if you enter "
>> http://localhost:2000/" in your web browser you get the expected
>> behavior. Is your Apache web server listening on port 2000? The 
>>reason I
>> ask that question is due to your statement that "any requests the 
>>app makes
>> are sent to localhost:2000". Which implies the app in question is 
>>directly
>> connecting to the backend without being proxied by the Apache httpd
>> process. What is this "app" and is it connecting to port 2000 or 
>>port 80 on
>> the local host?
>>
>> What is the "app" in the statement "any requests the app makes"? Is 
>>it a
>> web browser or something else? And if something else please provide 
>>more
>> details. What do you mean by "the remote IP address is shown as
>> localhost:80"? Shown where? By what program?
>>
>> --
>> Kurtis Rader
>> Caretaker of the exceptional canines Junior and Hank
>>



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Re: Proxying From Directory To App On Port

Posted by Steven Shi <st...@gmail.com>.
My webserver is not listening on port 2000, the Jetty back end server of
the app is. The app is a maven build of apache spark which runs the Jetty
server; I have it set to listen on port 2000.

The app in "any requests the app makes" would be the frontend of the server
that uses jquery for requests.

The remote IP as shown from the developers console in Google chrome. I
looked at the failed GET request.

I know the problem is not caused by the SSL rewrite (tested by turning of
SSL module).

On Tue, Aug 25, 2015 at 1:28 AM, Kurtis Rader <kr...@skepticism.us> wrote:

> On Mon, Aug 24, 2015 at 9:52 PM, Steven Shi <st...@gmail.com>
> wrote:
>
>> I have looked at and tried using the ProxyPassReverse directive.
>>
>> So the app communicates with the back end over port 2000.  Any requests
>> the app makes are sent to localhost:2000/foo to be processed by the back
>> end.
>>
>> Currently the relevant configuration is
>>
>> ProxyPass /app http://localhost:2000
>> ProxyPassReverse /app http://localhost:2000
>>
>> Basically, when the frontend of the app at localhost:2000 sends a GET
>> request, it's being sent as localhost:80/request rather than
>> localhost:2000/request.  Likewise, the remote IP address is shown as
>> localhost:80 rather than localhost:2000.
>>
>> If I go straight to localhost:2000, the app works as intended and makes
>> all requests to localhost:2000/request while showing the remote IP to be
>> localhost:2000.
>>
>
> I can appreciate that you are frustrated by seemingly non-sensical
> behavior from the programs you're working with. I recently experienced a
> similar situation when trying to setup a virtual host that would proxy
> requests to another http server while the Apache httpd daemon also honored
> my mod_rewrite rules for blacklisted sources which should not be proxied.
> It took me several hours to figure out how to configure Apache httpd to do
> what I wanted. Nonetheless, your description of the situation is incoherent.
>
> Let us start with your last paragraph where you say "If I go straight to
> localhost:2000". I assume you are saying that if you enter "
> http://localhost:2000/" in your web browser you get the expected
> behavior. Is your Apache web server listening on port 2000? The reason I
> ask that question is due to your statement that "any requests the app makes
> are sent to localhost:2000". Which implies the app in question is directly
> connecting to the backend without being proxied by the Apache httpd
> process. What is this "app" and is it connecting to port 2000 or port 80 on
> the local host?
>
> What is the "app" in the statement "any requests the app makes"? Is it a
> web browser or something else? And if something else please provide more
> details. What do you mean by "the remote IP address is shown as
> localhost:80"? Shown where? By what program?
>
> --
> Kurtis Rader
> Caretaker of the exceptional canines Junior and Hank
>

Re: [users@httpd] Re: Proxying From Directory To App On Port

Posted by Kurtis Rader <kr...@skepticism.us>.
On Mon, Aug 24, 2015 at 9:52 PM, Steven Shi <st...@gmail.com> wrote:

> I have looked at and tried using the ProxyPassReverse directive.
>
> So the app communicates with the back end over port 2000.  Any requests
> the app makes are sent to localhost:2000/foo to be processed by the back
> end.
>
> Currently the relevant configuration is
>
> ProxyPass /app http://localhost:2000
> ProxyPassReverse /app http://localhost:2000
>
> Basically, when the frontend of the app at localhost:2000 sends a GET
> request, it's being sent as localhost:80/request rather than
> localhost:2000/request.  Likewise, the remote IP address is shown as
> localhost:80 rather than localhost:2000.
>
> If I go straight to localhost:2000, the app works as intended and makes
> all requests to localhost:2000/request while showing the remote IP to be
> localhost:2000.
>

I can appreciate that you are frustrated by seemingly non-sensical behavior
from the programs you're working with. I recently experienced a similar
situation when trying to setup a virtual host that would proxy requests to
another http server while the Apache httpd daemon also honored my
mod_rewrite rules for blacklisted sources which should not be proxied. It
took me several hours to figure out how to configure Apache httpd to do
what I wanted. Nonetheless, your description of the situation is incoherent.

Let us start with your last paragraph where you say "If I go straight to
localhost:2000". I assume you are saying that if you enter "
http://localhost:2000/" in your web browser you get the expected behavior.
Is your Apache web server listening on port 2000? The reason I ask that
question is due to your statement that "any requests the app makes are sent
to localhost:2000". Which implies the app in question is directly
connecting to the backend without being proxied by the Apache httpd
process. What is this "app" and is it connecting to port 2000 or port 80 on
the local host?

What is the "app" in the statement "any requests the app makes"? Is it a
web browser or something else? And if something else please provide more
details. What do you mean by "the remote IP address is shown as
localhost:80"? Shown where? By what program?

-- 
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank

[users@httpd] Re: Proxying From Directory To App On Port

Posted by Steven Shi <st...@gmail.com>.
I have looked at and tried using the ProxyPassReverse directive.

So the app communicates with the back end over port 2000.  Any requests the
app makes are sent to localhost:2000/foo to be processed by the back end.

Currently the relevant configuration is

ProxyPass /app http://localhost:2000
ProxyPassReverse /app http://localhost:2000

Basically, when the frontend of the app at localhost:2000 sends a GET
request, it's being sent as localhost:80/request rather than
localhost:2000/request.  Likewise, the remote IP address is shown as
localhost:80 rather than localhost:2000.

If I go straight to localhost:2000, the app works as intended and makes all
requests to localhost:2000/request while showing the remote IP to be
localhost:2000.

On Tuesday, August 25, 2015, Kurtis Rader <kr...@skepticism.us> wrote:

> On Mon, Aug 24, 2015 at 8:30 PM, Steven Shi <steven200796@gmail.com
> <javascript:_e(%7B%7D,'cvml','steven200796@gmail.com');>> wrote:
>
>> I'm trying to proxy /app to localhost:2000 (where the app is hosted).
>> Unfortunately, whenever the app makes a GET/POST request, the port 2000 is
>> lost and the request is made to localhost:80 rather than localhost:2000.
>>
>> I feel as if the solution is something simple but I haven't been able to
>> discover it from three days of trial and error.
>>
>
> Too little data for a meaningful response. But have you looked at
> the ProxyPassReverse directive?
>
> If adding a ProxyPassReverse directive doesn't solve your problem you'll
> need to tell us about the relevant portions of your web server config and
> how you are testing the behavior. In particular it is not clear what you
> mean by "whenever the app makes a GET/POST request" since you also say "the
> app is hosted" at localhost:2000. In other words the flow of requests and
> responses is not clear from your description.
>
> --
> Kurtis Rader
> Caretaker of the exceptional canines Junior and Hank
>

Re: [users@httpd] Proxying From Directory To App On Port

Posted by Kurtis Rader <kr...@skepticism.us>.
On Mon, Aug 24, 2015 at 8:30 PM, Steven Shi <st...@gmail.com> wrote:

> I'm trying to proxy /app to localhost:2000 (where the app is hosted).
> Unfortunately, whenever the app makes a GET/POST request, the port 2000 is
> lost and the request is made to localhost:80 rather than localhost:2000.
>
> I feel as if the solution is something simple but I haven't been able to
> discover it from three days of trial and error.
>

Too little data for a meaningful response. But have you looked at
the ProxyPassReverse directive?

If adding a ProxyPassReverse directive doesn't solve your problem you'll
need to tell us about the relevant portions of your web server config and
how you are testing the behavior. In particular it is not clear what you
mean by "whenever the app makes a GET/POST request" since you also say "the
app is hosted" at localhost:2000. In other words the flow of requests and
responses is not clear from your description.

-- 
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank