Apache to 4D

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Apache to 4D

jarosz
I have an Apche web server running in front of a 4D web server.

I am trying to get a URL like

http://www.domain.com/index.html 

to redirect to

http://10.10.10.10:8080/index.html 

whilst still leaving the www.domain.com URL showing in the user's browser.

I have tried a few combinations of redirect or rewrite statements already without success.

Any help on the right syntax to use would be much appreciated.

Michael Jarosz
Reply | Threaded
Open this post in threaded view
|

Re: Apache to 4D

Sannyasin Siddhanathaswami
A week or two ago, I did just this but used nginx. I was thinking to submit what I learned so 4D could rewrite it and create a tech note. This was critical to becoming PCI compliant.

It was actually super simple. I know this isn’t instructions for Apache, but hopefully this working example configuration points you in the right direction.

1. Install nginx (I’m on a mac so I did it via Homebrew)
2. Configure as a proxy using proxy_pass (reasonable tutorial: https://gist.github.com/soheilhy/8b94347ff8336d971ad0)

3. Adjust the config section to have this:
server {
       listen       8080 ssl;
       server_name  your.domain.com;


       ssl_certificate      “/pathtoSSL/cert.pem";
       ssl_certificate_key  "/pathtoSSL/key.pem";


       ssl_session_cache    shared:SSL:1m;
       ssl_session_timeout  5m;
       ssl_protocols  TLSv1.1 TLSv1.2;
       ssl_ciphers  HIGH:!aNULL:!MD5;
       ssl_prefer_server_ciphers  on;


       location / {
          proxy_pass <a href="http://192.111.111.10:8088;">http://192.111.111.10:8088;
       }
    }

This only listens on port 8080 via SSL, then proxy_pass to http://192.111.111.10:8088.

4. Be sure to update your Web/Configuration preferences in 4D so that it’s not active on port 8080. In my case I changed the HTTPS port to a random higher number, and the "TCP Port: to 8088”





--
Sannyasin Siddhanathaswami



On July 8, 2016 at 9:35:52 PM, jarosz ([hidden email]<mailto:[hidden email]>) wrote:

I have an Apche web server running in front of a 4D web server.

I am trying to get a URL like

http://www.domain.com/index.html

to redirect to

http://10.10.10.10:8080/index.html

whilst still leaving the www.domain.com URL showing in the user's browser.

I have tried a few combinations of redirect or rewrite statements already
without success.

Any help on the right syntax to use would be much appreciated.

Michael Jarosz




--
View this message in context: http://4d.1045681.n5.nabble.com/Apache-to-4D-tp5746001.html
Sent from the 4D Tech mailing list archive at Nabble.com.
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:[hidden email]
**********************************************************************
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: Apache to 4D

Lee Hinde
In reply to this post by jarosz
Comments below assume you're on a Mac. The only thing that changes for
windows is the standard web directory

# add this with all the other LoadModule commands. It may be there and just
commented out.
LoadModule rewrite_module libexec/apache2/mod_rewrite.so

#stick this somewhere; I have mine towards the bottom, but it can be in its
own file too.

<IfModule mod_rewrite.c>
RewriteEngine on
# logging if you want it.
RewriteLog "/tmp/rewriteldh.log"
RewriteLogLevel 0
RewriteEngine on
# next 2 lines mean, if it's not a Get or  Post, ignore it.
RewriteCond %{REQUEST_METHOD} !^(POST|GET)$
RewriteRule .* - [F,L]
#may not be required, not sure. No harm
RewriteCond %{REQUEST_METHOD} .*
# if the file requested ends in any of the extensions below, handle it
# via static content. This assumes the root folder is called 'web'
# and lives in the /Library/WebServer/Documents/web
# you can also create a symlink from that directory to whereever your app
# really lives.  The [L] tells apache to quit monitoring  this request
RewriteRule ^/(.*\.(js|gif|jpeg|jpg|css|ico|png|zip))$ /web/$1 [L]
# this send everything else to 4D at port 8080, on the same machine
RewriteRule ^/(.*)$ http://localhost:8080/$1 [P,L]
</IfModule>

On Sat, Jul 9, 2016 at 12:35 AM, jarosz <[hidden email]> wrote:

>
> I have an Apche web server running in front of a 4D web server.
>
> I am trying to get a URL like
>
> http://www.domain.com/index.html
>
> to redirect to
>
> http://10.10.10.10:8080/index.html
>
> whilst still leaving the www.domain.com URL showing in the user's browser.
>
> I have tried a few combinations of redirect or rewrite statements already
> without success.
>
> Any help on the right syntax to use would be much appreciated.
>
> Michael Jarosz
>
>
>
>
> --
> View this message in context:
http://4d.1045681.n5.nabble.com/Apache-to-4D-tp5746001.html
> Sent from the 4D Tech mailing list archive at Nabble.com.
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:[hidden email]
> **********************************************************************
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: Apache to 4D

Dave Nasralla
In reply to this post by jarosz
Hi Michael,

I ended up purchasing "The Definitive Guide to Apache mod_rewrite"
used on Amazon.
http://www.amazon.com/dp/1590595610

After reading it I was able to get some of my re-write rules done
(including passing the IP address of the client on to the 4D Server so
I could record it.) Of course, I have forgotten everything now. But
here are some notes I wrote related to one of the rules. Hope its
helpful. The rule is for capturing a request for a file with an ID.

dave

-------------------------
The query (last portion after the ?) of the URL is not actually passed
on and must be manually added using environment variables which take
the form of %{VARIABLE_NAME}. The two key variables are:

·      REMOTE_ADDR which is the Clients IP address. Without this, 4D
will record the Client IP as the MacMini’s address.

·      QUERY_STRING which is everything after the ? in the original
request – not passed on automatically.



Third Rule: RewriteRule (/gofile/.*)
http://209.125.143.202:3000/4dcgi$1
?%{QUERY_STRING}&clientip=%{REMOTE_ADDR} [P]



These rules are pretty similar. They look for any URI that starts with
‘/getfile/’ or ‘/gofile/’ . The .* at the end captures the rest of the
URI, and because it is enclosed in parenthesis, it is stored as $1
-------------


d

On Sat, Jul 9, 2016 at 1:35 AM, jarosz <[hidden email]> wrote:

> I have an Apche web server running in front of a 4D web server.
>
> I am trying to get a URL like
>
> http://www.domain.com/index.html
>
> to redirect to
>
> http://10.10.10.10:8080/index.html
>
> whilst still leaving the www.domain.com URL showing in the user's browser.
>
> I have tried a few combinations of redirect or rewrite statements already
> without success.
>
> Any help on the right syntax to use would be much appreciated.
>
> Michael Jarosz
>
>
>
>
> --
> View this message in context: http://4d.1045681.n5.nabble.com/Apache-to-4D-tp5746001.html
> Sent from the 4D Tech mailing list archive at Nabble.com.
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:[hidden email]
> **********************************************************************



--
David Nasralla
Clean Air Engineering
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: Apache to 4D

David Adams-4
Yes, mod_rewrite. Such a pleasure. I was just enjoying it today as I want
to turn something like this;

/comparison/australia/norway/index.html

into something like this

php/compare.php?area_1=australia&area_2=norway

or so...

Anyway, the following is one of the nicer cookbook/tutorials I remember
seeing;

https://www.digitalocean.com/community/tutorials/how-to-set-up-mod_rewrite

Note that your Apache version may make a difference in some ways. With 2.4,
it appears that the old mod_rewrite-specific log is no more. I turned on
general logging (LogLevel) but didn't find the mod_rewrite dumps
particularly useful. That might just be me. In any case, if you see debug
tips and details, check that they apply to your version of Apache.

One great thing about mod_rewrite & Apache is that once they're working,
they just keep on working.



On Tue, Jul 12, 2016 at 6:35 AM, Dave Nasralla <[hidden email]> wrote:

> Hi Michael,
>
> I ended up purchasing "The Definitive Guide to Apache mod_rewrite"
> used on Amazon.
> http://www.amazon.com/dp/1590595610
>
> After reading it I was able to get some of my re-write rules done
> (including passing the IP address of the client on to the 4D Server so
> I could record it.) Of course, I have forgotten everything now. But
> here are some notes I wrote related to one of the rules. Hope its
> helpful. The rule is for capturing a request for a file with an ID.
>
> dave
>
> -------------------------
> The query (last portion after the ?) of the URL is not actually passed
> on and must be manually added using environment variables which take
> the form of %{VARIABLE_NAME}. The two key variables are:
>
> ·      REMOTE_ADDR which is the Clients IP address. Without this, 4D
> will record the Client IP as the MacMini’s address.
>
> ·      QUERY_STRING which is everything after the ? in the original
> request – not passed on automatically.
>
>
>
> Third Rule: RewriteRule (/gofile/.*)
> http://209.125.143.202:3000/4dcgi$1
> ?%{QUERY_STRING}&clientip=%{REMOTE_ADDR} [P]
>
>
>
> These rules are pretty similar. They look for any URI that starts with
> ‘/getfile/’ or ‘/gofile/’ . The .* at the end captures the rest of the
> URI, and because it is enclosed in parenthesis, it is stored as $1
> -------------
>
>
> d
>
> On Sat, Jul 9, 2016 at 1:35 AM, jarosz <[hidden email]> wrote:
> > I have an Apche web server running in front of a 4D web server.
> >
> > I am trying to get a URL like
> >
> > http://www.domain.com/index.html
> >
> > to redirect to
> >
> > http://10.10.10.10:8080/index.html
> >
> > whilst still leaving the www.domain.com URL showing in the user's
> browser.
> >
> > I have tried a few combinations of redirect or rewrite statements already
> > without success.
> >
> > Any help on the right syntax to use would be much appreciated.
> >
> > Michael Jarosz
> >
> >
> >
> >
> > --
> > View this message in context:
> http://4d.1045681.n5.nabble.com/Apache-to-4D-tp5746001.html
> > Sent from the 4D Tech mailing list archive at Nabble.com.
> > **********************************************************************
> > 4D Internet Users Group (4D iNUG)
> > FAQ:  http://lists.4d.com/faqnug.html
> > Archive:  http://lists.4d.com/archives.html
> > Options: http://lists.4d.com/mailman/options/4d_tech
> > Unsub:  mailto:[hidden email]
> > **********************************************************************
>
>
>
> --
> David Nasralla
> Clean Air Engineering
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:[hidden email]
> **********************************************************************
>
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

RE: Apache to 4D

Timothy Penner
In reply to this post by jarosz
Hi Michael,

I am coming to this topic a bit late, but we have the following Tech Note from 2009 on the 4D Knowledge Base (I searched for 'apache' on kb.4d.com):

Tech Note: Apache, Mod_Proxy, & 4D
http://kb.4d.com/assetid=75920

This Technical Note discusses how to use Apache HTTP Server as a front end to 4D’s Web Server. This is achieved through the use of the mod_proxy module. Various sample configurations are given and their options are discussed. This information should give the 4D Developer the knowledge necessary to provide an Apache front end to their 4D Web Server if their clients request it.

I hope this helps:

-Tim PENNER




**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: Apache to 4D

JasonH
In reply to this post by jarosz
I can't help you with the Apache config, but if you aren't married to using Apache you can check out NGINX.  I've heard it's a bit easier and streamlined to use compared to Apache.  You can search the NUG to find other posts about it, but here is a post I made with my config.

http://4d.1045681.n5.nabble.com/NGINX-Config-td5733806.html

Either way, hope you get your website working!