Hi there

I know... I know... this is problably more an Apache question than Perl. But since it does involve Dancer2 I hope one of you has some experience with this. So this is my problem:

I've been doing a lot of work on Azure. using LWP to do the Graph requests. Usually just cli/backend scripting, which works just fine. But Dancer2 gets me into trouble. Azure, like other oAuth API's, needs a callback URI to accept an authentication attempt. This works just fine during development: doing port forwarding to the development host. In this case Azure gets a callback URI like http://localhost/azuread/callback

The problems start when going to production. Azure no longer receives a callback URI which can work, it should get something like https://somesite/azuread/callback, but "somesite" is replaced by the servers IP. I found the callback uri is composed of some variables, one of them being "base". This variable is by default initialized using the request URI, or can be set in the config. So I would be able to set a correct base by putting it in the config, but I'd rather have the default method of using the request URI which comes from Apache (in my case)

I'm using an Apache2 vhost with a fcgid setup, some rewrite rules "forward" the request to the dispatch.fcgi. I found a deployment guide for Dancer2 apps and am using a modified version of the fastcgi setup. I could not find an easy way to get mod_fastcgi on my host, but could get mod_fcgid from the Ubuntu repro, I adapted the vhost for mod_fcgid. And I guess something goes wrong there. This is the vhost.conf:

<VirtualHost *:80>
    ServerName somesite.somehost.nl
    DocumentRoot /var/www/somesite/public
    Redirect permanent / https://somesite.somehost.nl
</VirtualHost>
<VirtualHost *:443>
    ServerName somesite.somehost.nl
    DocumentRoot /var/www/somesite/public

    <Directory /var/www/somesite/public>
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        #AddHandler fastcgi-script .fcgi
        AddHandler fcgid-script .fcgi
        Require all granted
    </Directory>
    ErrorLog  /var/log/apache2/somesite/error_log
    CustomLog /var/log/apache2/somesite/access_log common

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ /dispatch.fcgi$1 QSA,L

    Include cert/wildcard.conf
</VirtualHost>

I suspect the Rewrite setting to be at fault. I did find settings for mod_proxy to infuence the request uri, but I'm not using mod_proxy as far as I know

Any thoughts?

Peter


In reply to Dancer2 getting a wrong request uri by PeterKaagman

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.