実際の実稼働環境でeXist-dbアプリケーションを設定しようとしています。これは、localhost
またはIPアドレスの代わりにドメイン名を使用することを意味します。純粋なIPでサーバーにアクセスすると、すべてが機能します。ドメイン名でアクセスすると、ページごとにしかログオンできません。私はログインすると、すぐに私は別のリンク(または現在のものを再度訪問しようとすると!)アプリのページで、私はログアウトしています。サーバがドメイン名(IPではなく)にアクセスすると、ユーザセッションがeXist-dbに保存されない
マイコントローラ:
xquery version "3.0";
import module namespace login="http://exist-db.org/xquery/login" at "resource:org/exist/xquery/modules/persistentlogin/login.xql";
declare variable $exist:path external;
declare variable $exist:resource external;
declare variable $exist:controller external;
declare variable $exist:prefix external;
declare variable $exist:root external;
declare variable $local:login_domain := 'domain-x';
let $set-user := login:set-user($local:login_domain,(), false())
(: Here we are grabbing all names of user's groups. :)
let $user := request:get-attribute('domain-x.user')
let $groups := if ($user) then string-join(sm:get-user-groups($user), ', ') else 'NoGroup'
return
if ($exist:path eq '/'or $exist:resource eq 'index.html') then
<dispatch xmlns='http://exist.sourceforge.net/NS/exist'>
<forward url='{$exist:controller}/index.html'/>
<view>
<forward url="{$exist:controller}/modules/view.xql"/>
</view>
<error-handler>
<forward url="{$exist:controller}/error-page.html" method="get"/>
<forward url="{$exist:controller}/modules/view.xql"/>
</error-handler>
</dispatch>
else if (
($exist:path eq '/create-ebooks-search.html') or
($exist:path eq '/create-ebooks-list.html') or
($exist:path eq '/metadata-tool.html') or
($exist:path eq '/testing.html') or
($exist:path eq '/create-ejournals-list.html')
)
then
if (contains($groups, 'editors')) then
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<!-- All sites are placed in the 'secure' directory,
links to them are as if they were in the root of the app,
hence the forwarding. -->
<forward url='{$exist:controller}/secure/{$exist:resource}'/>
<view>
<forward url="{$exist:controller}/modules/view.xql">
<set-attribute name="hasAccess" value="true"/><!-- Only for reference -->
<set-attribute name="$exist:prefix" value="{$exist:prefix}/secure"/>
<set-attribute name="$exist:controller" value="{$exist:controller}"/>
<!-- This is very important, without this or similar header, authentication
does not work properly—login and logout does not work as expected,
on some sites is is detected by the template, on some it is not.
It is possible to use other headers, works as well:
private, no-store, max-age=0, no-cache, must-revalidate are useful.
It is necessary to use it for the forward action of the view. -->
<set-header name="Cache-Control" value="no-cache"/>
</forward>
</view>
<error-handler>
<forward url="{$exist:controller}/error-page.html" method="get"/>
<forward url="{$exist:controller}/modules/view.xql"/>
</error-handler>
</dispatch>
...
UPDATE
クッキーと関連付けることができそうです。 IPアドレスでアクセスしたページにログインしようとすると、org.exist.login
というCookieが保存され、サイトのページに渡されます。ドメイン名でアクセスしたページにログインしようとすると、Cookieが見つかりません。
UPDATE II
私は、Redbird経由で私の設定をプロキシています:
var proxy = require('redbird')({
port:80,
ssl: {
port: 443
}
});
proxy.register('my-app.domain.com', 'http://xx.xx.xxx.xxx:8081/exist/apps/my-app', {
ssl: {
key: '../SSL-certs/dev-key.pem',
cert: '../SSL-certs/dev-cert.pem',
}
});
(私はthis questionで説明letsencryptを、使用することができませんでした。)
私は株式eXist(埋め込まれたJetty HTTPサーバーを使用している)、リバースプロキシの役割を果たす他のサーバー(Apache、Nginxなど)がないとしますか?また、どのバージョンのeXist? – joewiz
3.0.RC1版です。リバースプロキシとして、私は[Redbird](https://github.com/OptimalBits/redbird)を使用しています(非常に軽く設定が簡単なので)。 –
Redbirdがアクティブで、純粋なIPとドメイン名の両方のシナリオでバイパスされないようにすることはできますか? Redbirdの設定ファイルをカスタマイズした場合は、それを投稿することができます。関連性があります。 – joewiz