3

Initial post

I've posted about my issue on the Mojolicious forum but am still looking for a solution.

For various reasons I'm trying to get some Mojolicious apps I've written to run on IIS. I have a 7.5 (2k8r2) and 8.5 (2k12r2) server to test with.

The IIS setup is very basic. I created a new application under the Default Web Site, pointed it to the code, added the Perl Handler Mapping, and added a default document. The path to the site is http://server.example.com/sessiontest/

After getting the site setup and running, everything is working as expected except that sessions are not working. I wrote a test app to test with. At the start of the script I'm setting up the session:

# Setup sessions
app->secrets(['SessionTest']);
app->sessions->cookie_name('sessiontest');

Setting the session variable:

get '/set' => sub {
 my $c = shift;
 
 $c->session(testvar => 1);
 $c->redirect_to('/');
};

And testing to see if it exists with a helper:

helper testvar => sub {
 my $c = shift;
 
 if($c->session('testvar')) {
  return 1;
 }
 
 return undef;
};

When I run the code with Morbo on either server it runs fine and sessions are working. But under IIS I get nothing.

One of the suggestions I received was to look at the cookie domain and cookie path. As a test I tried setting a test domain name in the hosts file of the server and the client for the servers IP at test.example.com. I them added:

app->sessions->cookie_domain('.example.com');
app->sessions->cookie_path('/sessiontest');

I'm assuming the cookie_path should be '/' which I have also tried with no luck.

Any help would be appreciated!

IIS Config

This is a freshly installed W2k12R2 box running IIS 8.5. I have ActivePerl 5.24 installed. The config is as basic as I can get. Here's the steps I took to configure IIS.

  • Install IIS w/ CGI support
  • Copy test app to C:\Code\sessiontest\
  • From Default Web Site -> Add Application
  • Alias: sessiontest, Physical path: C:\Code\sessiontest\
  • Select sessiontest application
  • Add Handler Mapping for *.pl to C:\Perl64\bin\perl.exe "%s" %s
  • Add Default Document for app.pl

Output from curl

Result from curl to the IIS server.

curl -I http://server.example.com/sessiontest/app.pl/set
HTTP/1.1 200 OK
Content-Length: 160
Content-Type: text/html;charset=UTF-8
Server: Microsoft-IIS/7.5
[Thu Aug  3 19: 49:38 2017] [debug] HEAD "/"
[Thu Aug  3 19: 49:38 2017] [debug] Routing to a callback
[Thu Aug  3 19: 49:38 2017] [debug] Rendering template "index.html.ep" from DATA section
[Thu Aug  3 19: 49:38 2017] [debug] Rendering template "layouts/default.html.ep" from DATA section
[Thu Aug  3 19: 49:38 2017] [debug] 200 OK (0.002271s, 440.335/s)
Date: Thu, 03 Aug 2017 23:49:38 GMT

Versus the result of running from Morbo

curl -I http://server.example.com:3000/set
HTTP/1.1 302 Found
Content-Length: 0
Date: Thu, 03 Aug 2017 23:51:29 GMT
Location: /
Server: Mojolicious (Perl)
Set-Cookie: sessiontest=eyJleHBpcmVzIjoxNTAxODA3ODg5LCJ0ZXN0dmFyIjoxfQ----96063fca63a3457e89becc55d7df39898466bb99; expires=Fri, 04 Aug 2017 00:51:29 GMT; path=/; HttpOnly

I set the mode to production and now I'm getting something closer on IIS.

curl -I http://server.example.com/sessiontest/app.pl/set
HTTP/1.1 200 OK
Content-Length: 160
Content-Type: text/html;charset=UTF-8
Server: Microsoft-IIS/7.5
Date: Fri, 04 Aug 2017 00:04:30 GMT
Community
  • 1
  • 1
  • The curl tests showed that the code was running in development mode which was passing the debug messages to headers. Makes sense. But it's still not passing cookies. – Brandon Woodson Aug 04 '17 at 00:13
  • 1
    Okay, I've added the steps I used to install and configure IIS. I'm using ActivePerl 5.24 with the only extra module installed being Mojolicious 7.25. – Brandon Woodson Aug 04 '17 at 01:35
  • OK, I spent quite some time trying to figure out what is going on with no success here. Please do update us if you do figure it out. Sorry couldn't be of more help. – Sinan Ünür Aug 04 '17 at 16:08
  • Thanks for taking a look! I'll update the thread as my troubleshooting continues. – Brandon Woodson Aug 05 '17 at 01:30

0 Answers0