DSP running under Nginx?

Hi -

Curious if anyone has tried to run DSP under Nginx? Seems out of the box, only Apache is supported at this time. Nginx is my web server of preference, would be great to run on that web server as well.

I’m imagining the work is primarily in Nginx configuration, to respect the same rewrite rules that .htaccess provides under Apache. If this hasn’t been experimented with yet, I may take a crack at converting Apache config to Nginx. Would love to hear thoughts, potential pitfalls or prior experiences.

Thanks,

Jason

Hi Jason,

Yes, please take a crack at it. I’ll ask Jerry about specific changes required and post any info.

Cheers,
Ben

Hey Jason,

Jerry is actually working on Nginx config now and says he should have the info by Tuesday. I’ll post details shortly.

Hi Ben,

That’s really good news and glad to hear Jerry is working down this path!

Once available, I’m happy to help test and validate along with the team as well.

Many thanks,

Jason

Hi Jason,

Jerry just wrote up some instructions for using DreamFactory with Nginx. Please give it a shot and let us know if you have any feedback.

Thanks,
Ben

Thanks Ben and team!

Apologies on the delay in response, we’ve been on vacation overseas with limited access to Internet. Looking forward to testing this out in the weeks ahead.

At first read, I thought this was a Nginx proxy configuration, which I have set up today and works quite well. Looks like Jerry removed the proxy configuration for direct PHP processing which is exciting and the solution I was seeking. As soon as the time becomes available, I’ll make sure to implement from these great instructions and report back on the results.

Thanks,

Jason

Excellent, let us know how it goes!

Hi there - still working through this, seem to be getting close on config, however getting an error:

Fatal error: Wrong parameters for Exception([string $exception [, long $code [, Exception $previous = NULL]]]) in /var/www/[website]/vendor/kisma/kisma/src/Kisma/Core/Exceptions/SeedException.php on line 64

I’m sure it is my web server config, maybe missing a requirement or so. I’ll keep plugging away as time permits.

Hey Jason, I’ve been away on vacation. Did you sort out the config?

Hi Ben -

Just gave this another run through with 1.7.6. I got this to work and it works really well under Nginx!!

Only minor feedback I have is the team may want to consider cleaning up the Apache language under the wiki article: https://github.com/dreamfactorysoftware/dsp-core/wiki/Configuring-nginx. My config is running 100% under Nginx, no Apache installed on my virtual box whatsoever. For the other users which will attempt Nginx + DSP, the Apache text may lead them to believe Nginx is a proxy to Apache, however this works really well with just Nginx (thereby saving a lot of overhead on small 512 MB virtual boxes).

Mega thanks to Jerry for putting this together!!!

Also, I haven’t fully tested to see if there are any downsides to this, but I was able to run one config for both HTTP 80 and HTTPS 443. Is easier for me to read the config, I’ll share below if helpful to others:

server {
        listen 80;
        listen 443 ssl;
        server_name dreamfactory.website.null;
        root /var/www/dreamfactory.website.null/web;
        index index.php index.html;

        ssl on;
        ssl_certificate /etc/nginx/ssl/server.crt;
        ssl_certificate_key /etc/nginx/ssl/server.key;
        ssl_session_timeout 5m;
        ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
        ssl_prefer_server_ciphers on;

        location / {
                try_files $uri $uri/ /index.php?$args;
        }

        location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar|mustache)$ {
                try_files $uri =404;
        }

        location ~* ^.*\.php$ {
                try_files $uri =404;

                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }

        location ~ /\. {
                deny all;
                access_log off;
                log_not_found off;
        }
}
1 Like

Awesome, glad it’s working! Thanks for the feedback too, I’ll let Jerry know.

Hey Jason! Thanks for the props!

I’ve been working on some better configuration examples for nginx. My goal in that wiki page was to set up an nginx proxy to an apache back-end so a varnish cache could be easily utilized. In addition, as you stated, SSL runs only on nginx and apache can be on a single port. Mainly, I wanted to provide a method to incorporate nginx into a default DSP installation.

You can ABSOLUTELY run without apache. It works fine and is faster. That said, I’ve created sample configurations for this scenario and they are currently in the develop branch of the dsp-core repo.

As for combining the configs into a single server, I am not sure. My nginx kung fu is weak in that area. But if you get it to work, please let me know. As it stands now, there is a single config file with two servers defined, http and https. This is in the config examples in the repo.

We will be pushing a new 1.7 update this week (hopefully) to address this and a few other minor issues found since release. I’ll update the wiki to better explain the purpose, and create a second page for a stand-alone nginx config. Cool?

Jason, I put together of set of nginx configs and some basic doc.

The files are all under the config/exernal/nginx directory in the repo. Drill down to the sites-available directory where one will find two example server configs.

The first (dsp.multi.local) defines two server clauses. One for http, and one for https.

The second (dsp.single.local) defines a single server clause (per your suggestion above).

The configs mentioned above depend on a few other files in that tree, so be aware and RTFW.

P.S. I’ve tested it on my box, on EC2, and a few PaaS systems. Works very well. Thanks for the suggestion!

Is it possible to force/redirect to https from http in dsp.local?

Also SSLv3 should be removed. (POODLE)

This SF post appears to be an accepted answer on how to force HTTPS in Nginx.