2016-11-09 4 views
1

実際の実稼働環境で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を、使用することができませんでした。)

+1

私は株式eXist(埋め込まれたJetty HTTPサーバーを使用している)、リバースプロキシの役割を果たす他のサーバー(Apache、Nginxなど)がないとしますか?また、どのバージョンのeXist? – joewiz

+0

3.0.RC1版です。リバースプロキシとして、私は[Redbird](https://github.com/OptimalBits/redbird)を使用しています(非常に軽く設定が簡単なので)。 –

+1

Redbirdがアクティブで、純粋なIPとドメイン名の両方のシナリオでバイパスされないようにすることはできますか? Redbirdの設定ファイルをカスタマイズした場合は、それを投稿することができます。関連性があります。 – joewiz

答えて

1

私はこれがあると思います本当にRedbirdの質問で、Redbirdがホスト名をeXistに渡しているかどうかと、このホスト名を持つeXistのset-cookieヘッダーをクライアントに戻すことができるかどうかが関係しています。比較のために、history.state.govのnginxのが設定されている方法を見る - https://github.com/HistoryAtState/hsg-project/blob/master/deploy/1861/etc/nginx/vhosts/1861.hsg.conf#L22-L24

proxy_pass_header  Set-Cookie; 
proxy_set_header  Host $host; 
proxy_set_header  X-Real-IP $remote_addr; 

ドメインを使用している場合のみ、IP対を使用した場合、クッキーは異なる動作方法を説明したこちらの記事を参照してください:How do browser cookie domains work?

私はRedbirdを使用していないので、正確なガイダンスは得られませんが、これらのnginx指令に対応するRedbirdの対応が見つからない場合は、Redbirdに関する質問を投稿することをお勧めします。

+0

私はApacheに近づいていますが、セッションやCookie(IEの場合)にはまだ苦労しています。後で問題をいくつかの解決策で更新します。今のところ私はあなたの答えを有効とマークします。どうもありがとう。 –

関連する問題