Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HttpPlatformHandler HTTP Error 502.3 - Bad Gateway

I am trying to run rails on IIS, I followed the steps mentioned here by Scott Hanselman.

Here's some info that might help:

  • Rails version: 5.1.4
  • Ruby version: 2.3.3

After I followed the setup steps, I countered this issue

HTTP Error 502.3 - Bad Gateway

There was a connection error while trying to route the request.

Most likely causes:

  • The CGI application did not return a valid set of HTTP errors.

  • A server acting as a proxy or gateway was unable to process the request due to an error in a parent gateway.

Things you can try:

  • Use DebugDiag to troubleshoot the CGI application.

  • Determine if a proxy or gateway is responsible for this error.

Here is my web.config file content.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="httpplatformhandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" requireAccess="Script" />
    </handlers>
    <httpPlatform processPath="C:\RailsInstaller\Ruby2.3.3\bin\ruby.exe" arguments="&quot;C:\RailsInstaller\Ruby2.3.3\bin\rails&quot; server -p %HTTP_PLATFORM_PORT% -b 127.0.0.1" startupTimeLimit="200" stdoutLogEnabled="true" stdoutLogFile="rails.log">
      <environmentVariables>
        <environmentVariable name="RAILS_ENV" value="development" />
      </environmentVariables>
    </httpPlatform>
    <directoryBrowse enabled="true" showFlags="Date, Time, Size, Extension" />
  </system.webServer>
</configuration>

I am not sure what the problem is, and what configurations I miss!

like image 721
Mahmoud Sayed Avatar asked Jan 03 '18 09:01

Mahmoud Sayed


3 Answers

you can read this comments

Sowmya

I did like its said in the post, but my app shows HTTP Error 502.3 - Bad Gateway There was a connection error while trying to route the request. Most likely causes: The CGI application did not return a valid set of HTTP errors. A server acting as a proxy or gateway was unable to process the request due to an error in a parent gateway. When browsing the file through IIS manager also i got the same error. But on running the rails app using webrick its working. Any idea what i did wrong here?

jaytho

Hey thanks for this writeup! I've been wrestling with this and am wondering how the hell you got this to work. httpPlatformHandler only supports IIS8.0+ which suggests 2012r2, and RubyOneclickInstaller doesn't fully support 2012r2. 2008 only right now- and when I try to install ruby git doesn't install completely on my test case of a shiny new AWS 2012r2 box. Sounds really promising, however. I got my app (with libV8 even) running on web brick on 2008r2, but no joy with the XML configs you have shown above (I get errors). I tried to install IIS8.0 limited version refuses to install, as well as the httpPlatformHandler. What exact platforms did you use? Thanks again for taking the time to write this up. Do'h! I grabbed ruby installer instead of rails installer. That is why git didn't install.

HostForLIFE.eu

Great information! Congrats to Microsoft for launch this HttpPlatformHandler. It's really interesting, running Ruby on Windows Environment. Our opinion that to run Ruby on Rails, it will better to use JRuby. Anyway, this is really interesting. We really look forward to check your next update. Regards

Thanks so much for the great article! I'm getting an error - maybe you can look at my question on Stack Overflow and see if you know the answer?

The discussion continues in this stackoverflow post

like image 129
Fabrizio Bertoglio Avatar answered Nov 13 '22 16:11

Fabrizio Bertoglio


Try with below web.config settings and add your project in directory C:\inetpub\wwwroot\ first:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="httpplatformhandler" path="*" verb="*"
        modules="httpPlatformHandler"
        resourceType="Unspecified" requireAccess="Script" />
    </handlers>
    <httpPlatform stdoutLogEnabled="true"
      startupTimeLimit="20"
      processPath="C:\Ruby21\bin\ruby.exe"
      arguments="C:\inetpub\wwwroot\rails_on_iis\bin\rails server -p %HTTP_PLATFORM_PORT% -b 127.0.0.1 -e production">
    </httpPlatform>
  </system.webServer>
</configuration>
like image 43
stefan Avatar answered Sep 25 '22 02:09

stefan


Try with below web.config settings and add your project in directory C:\inetpub\wwwroot\ first:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="httpplatformhandler" path="*" verb="*"
        modules="httpPlatformHandler"
        resourceType="Unspecified" requireAccess="Script" />
    </handlers>
    <httpPlatform stdoutLogEnabled="true"
      startupTimeLimit="20"
      processPath="C:\Ruby21\bin\ruby.exe"
      arguments="C:\inetpub\wwwroot\rails_on_iis\bin\rails server -p %HTTP_PLATFORM_PORT% -b 127.0.0.1 -e production">
    </httpPlatform>
  </system.webServer>
</configuration>
like image 2
youpilat13 Avatar answered Nov 13 '22 17:11

youpilat13