Re: Re: Proxying From Directory To App On Port

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

Inline image 2


The correct request arguments in the working app on the port are shown below
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@xxxxxxxxxxxx
        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@xxxxxxxxxxxx
                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 <krader@xxxxxxxxxxxxx> wrote:
On Tue, Aug 25, 2015 at 3:46 PM, Steven Shi <steven200796@xxxxxxxxx> 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 <rwebb@xxxxxxxxxxxx> 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


[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux