Score:1

Reverse Proxy config from Nginx to Ubuntu Apache2

tj flag

The following are 2 corresponding sets of config statements. The first one is for Nginx and the second one for Apache2 servers.

The Ubuntu Apache2 config code is modelled after the Nginx code to provide the same functionality.

The two config paragraphs work the same except that the Nginx code paragraph has an extra "set $args" statement.

# Nginx Sample

server {
        listen       80;             
        server_name  AAA.com www.AAA.com;         
              
        location /Test_Path  {
            set $args "$args&jscode=123456”;
            proxy_pass http://www.BBB.com/;
        }
}



# # # # # # # # # # # # # # # # # # # # # # # #


# Apache2 Sample

<VirtualHost *:80>

   ServerName  AAA.com
   ServerAlias www.AAA.com

   ProxyPass        /Test_Path  http://www.BBB.com/
   ProxyPassReverse /Test_Path  http://www.BBB.com/
  

</VirtualHost>

My question is :

How to add Apache2 config statement (or statements) which can function as the extra Nginx statement.

The extra Nginx statement is used to pass a private key string to a backend server from its reverse proxy. The statement is singled out and displayed below :

set $args "$args&jscode=123456”;

Background info of this question :

The Nginx config code was adopted from sample code from a service provider. I do not have any Nginx server to test it. But the code should work because it is from an established provider.

The Apache2 trial code was adapted from various sample code from the internet.

I have tested the Apache2 trial code quite thoroughly and it seems to work as expected.

The only thing left out of the Apache2 config trial code is the "set $args" statement.

The "set $args" statement is used to pass a private key to a backend server.

The service provider's technical support people say they only have sample config code for Nginx servers. They also say they are not familiar with Apache.

But the same support people also say Apache servers should work if they have reverse proxy capability.

I am new to web servers setup. But I have spent quite some time researching before coming up with this simplified trial code for testing on an Apache2 server.

If you have any insight into this please share some of your valuable advice and suggestions.

Any comments, advice or suggestions are appreciated. Looking forward to hear from you.

jabbson avatar
sb flag
I think you are looking for the [rewrite module](https://httpd.apache.org/docs/2.4/rewrite/) and RewriteRule that will append your arguments.
Stanley avatar
tj flag
Thanks for your comment, Jabbson. I will look into the "rewrite module" material to see if it is applicable.
Stanley avatar
tj flag
@jabbson, after looking into it, I think your rewrite module suggestion is very useful. But before constructing a corresponding rewrite directive, I need to determine what the output of the Nginx directive actually is. My guess is : "www.BBB.com?jscode=123456". And if there is already another argument then it would be like : "www.BBB.com?jsvalue=789&jscode=123456". Do you agree ?
jabbson avatar
sb flag
sure, maybe two rules with preceding RuleCond's on %{QUERY_STRING} then?
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.