A walk at the shore part II (configuring and using seaside with apache as a front-end)

Tagged:  •    •    •    •  

And it's me again...

I'm currently using seaside to create a new WEB-site and I want you to show something of the configuration I use for the connection between seaside and apache, and for configuring seaside through some lines of code instead doing it through the configuration-dialog of seaside.

Apache is configured in my case as a reverse proxy and I needed some time, to figure out, how both should be configured, to let the seaside generated sites display well. (Even with the halos etc.)

So here's the part, which I use for config my apache as the front-end. Let's assume, that my server is reachable under www.example.com and my application is named UrPics and should be available under http://www.example.com/urpics:

ProxyRequests Off
<Proxy *>
        Order deny,allow
        Allow from all
</Proxy>

ProxyPass /urpics http://www.example.com:8080/seaside/UrPics
ProxyPassReverse /urpics http://www.example.com:8080/seaside/Urpics
ProxyPass /seaside http://www.example.com:8080/seaside/
ProxyPassReverse /seaside http://www.example.com:8080/seaside/

The first 2 lines of ProxyPass and ProxyPassReverse are for the new seaside-application. Additionally, I'd like to use the seaside-dispatcher over the same server, to have access to the configure dialog, I added the second time a ProxyPass and ProxyPassReverse. (And even for the fact, that your seaside-page references some resources under http://yourhost/seaside/...)

But apache is not the only thing to configure. Here's a screenshot of the seaside-configuration I use for my application:

2420813.png

This is important, if you would like to access some resources for you application, which are saved under the apache-instance (e.g. /urpics/resources/logo.png or the style sheet under /urpics/resources/style.css - which should not be served directly through seaside in my opinion).

If you want to reference some resources from the apache side in your application, simply use the following for include e.g. the style-sheet into your application:

(This part seems to change a bit in the different versions of seaside... I found several howto's for this, but 2 of them doesn't work. This one works with the current master-branch of gst. 14. June 2009)

updateRoot: htmlRoot [
    super updateRoot: htmlRoot.
    htmlRoot title: 'urPics - your pictures on the WEB'.
    htmlRoot link
        type: 'text/css';
        beStylesheet;
        addAll;
        url: '/resources/style.css';
        yourself.
]

and the following code-snipet for include e.g. an image (picture) file into your generated web-site:

html image url: '/resources/urpics.png'.

But that's not all for today, here are some lines of code to do the settings of the picture above in the source-code of your application.

I was tiered in doing the settings through the configuration-dialog of seaside, after each start of the seaside server, because I actually don't know how to save an image from a running one, accessed only through gst-remote...

And the other reason is, I'm using a subclassed WASession with additional variables, and I access this session and the variables in the first web-page, which is diplayed, I have to set the configuration details as early as possible, otherwise, the web-application would crash, because of the missing fields...

In the class, which is my root-class of the application, I created an additional class-method initialize where I do the registration of my application into seaside and set afterwards some of the configuration parameter:

UPHome class >> initialize [
    | app |
    app := UrPics.UPHome registerAsApplication: 'UrPics'.
    app preferenceAt: #sessionClass put: UrPics.Session;
        preferenceAt: #serverHostname put: 'http://www.example.com';
        preferenceAt: #serverPath put: '/urpics/';
        preferenceAt: #decorationClasses put: (Array with: Seaside.WAToolDecoration).
]

and with:

app preferenceAt: #sessionExpirySeconds put: 1200.

you can even set the expiration seconds of your application.

(And you should see here, how it works, use only the configuration parameter name from the seaside-config dialog, change it to a camel-case selector-name and provide the parameter!)

After creating the above method, you only have to call it after loading your application like:

/opt/bin/gst-remote --eval 'UrPics.UPHome initialize'

Hope it will help you a little bit!

Happy coding!
Joachim.

User login