# DSP running under Nginx?

**URL:** <https://community.dreamfactory.com/t/dsp-running-under-nginx/161>\
**Category:** Miscellaneous\
**Created:** [July 13, 2014, 10:24am UTC](https://community.dreamfactory.com/t/dsp-running-under-nginx/161 "2014-07-13T10:24:58Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![jasonh](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/jasonh/32/1200_2.png) [@jasonh](https://community.dreamfactory.com/u/jasonh)\
**Post date:** [July 13, 2014, 10:24am UTC](https://community.dreamfactory.com/t/dsp-running-under-nginx/161/1 "2014-07-13T10:24:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![benbusse](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/benbusse/32/4_2.png) [@benbusse](https://community.dreamfactory.com/u/benbusse)\
**Post date:** [July 13, 2014, 3:46pm UTC](https://community.dreamfactory.com/t/dsp-running-under-nginx/161/2 "2014-07-13T15:46:35Z")

</div>

Hi Jason,

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

Cheers,  
Ben

---

<div class="post-metadata">

**Author:** ![benbusse](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/benbusse/32/4_2.png) [@benbusse](https://community.dreamfactory.com/u/benbusse)\
**Post date:** [July 13, 2014, 4:22pm UTC](https://community.dreamfactory.com/t/dsp-running-under-nginx/161/3 "2014-07-13T16:22:40Z")

</div>

Hey Jason,

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

---

<div class="post-metadata">

**Author:** ![jasonh](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/jasonh/32/1200_2.png) [@jasonh](https://community.dreamfactory.com/u/jasonh)\
**Post date:** [July 14, 2014, 3:54am UTC](https://community.dreamfactory.com/t/dsp-running-under-nginx/161/4 "2014-07-14T03:54:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![benbusse](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/benbusse/32/4_2.png) [@benbusse](https://community.dreamfactory.com/u/benbusse)\
**Post date:** [July 16, 2014, 7:40pm UTC](https://community.dreamfactory.com/t/dsp-running-under-nginx/161/5 "2014-07-16T19:40:13Z")

</div>

Hi Jason,

Jerry just wrote up some instructions for [using DreamFactory with Nginx](https://github.com/dreamfactorysoftware/dsp-core/wiki/Configuring-nginx). Please give it a shot and let us know if you have any feedback.

Thanks,  
Ben

---

<div class="post-metadata">

**Author:** ![jasonh](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/jasonh/32/1200_2.png) [@jasonh](https://community.dreamfactory.com/u/jasonh)\
**Post date:** [July 25, 2014, 10:23pm UTC](https://community.dreamfactory.com/t/dsp-running-under-nginx/161/6 "2014-07-25T22:23:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![benbusse](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/benbusse/32/4_2.png) [@benbusse](https://community.dreamfactory.com/u/benbusse)\
**Post date:** [July 26, 2014, 6:33am UTC](https://community.dreamfactory.com/t/dsp-running-under-nginx/161/7 "2014-07-26T06:33:00Z")

</div>

Excellent, let us know how it goes!

---

<div class="post-metadata">

**Author:** ![jasonh](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/jasonh/32/1200_2.png) [@jasonh](https://community.dreamfactory.com/u/jasonh)\
**Post date:** [August 7, 2014, 5:59pm UTC](https://community.dreamfactory.com/t/dsp-running-under-nginx/161/8 "2014-08-07T17:59:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![benbusse](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/benbusse/32/4_2.png) [@benbusse](https://community.dreamfactory.com/u/benbusse)\
**Post date:** [August 19, 2014, 3:09pm UTC](https://community.dreamfactory.com/t/dsp-running-under-nginx/161/9 "2014-08-19T15:09:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jasonh](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/jasonh/32/1200_2.png) [@jasonh](https://community.dreamfactory.com/u/jasonh)\
**Post date:** [August 20, 2014, 4:58am UTC](https://community.dreamfactory.com/t/dsp-running-under-nginx/161/10 "2014-08-20T04:58:40Z")

</div>

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](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:

```auto
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;
        }
}

```

---

<div class="post-metadata">

**Author:** ![benbusse](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/benbusse/32/4_2.png) [@benbusse](https://community.dreamfactory.com/u/benbusse)\
**Post date:** [August 20, 2014, 5:05am UTC](https://community.dreamfactory.com/t/dsp-running-under-nginx/161/11 "2014-08-20T05:05:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dfjablan](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/dfjablan/32/1201_2.png) [@dfjablan](https://community.dreamfactory.com/u/dfjablan)\
**Post date:** [August 20, 2014, 1:51pm UTC](https://community.dreamfactory.com/t/dsp-running-under-nginx/161/12 "2014-08-20T13:51:41Z")

</div>

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`](https://github.com/dreamfactorysoftware/dsp-core/tree/develop/config/external/nginx) 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?

---

<div class="post-metadata">

**Author:** ![dfjablan](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/dfjablan/32/1201_2.png) [@dfjablan](https://community.dreamfactory.com/u/dfjablan)\
**Post date:** [August 21, 2014, 6:23am UTC](https://community.dreamfactory.com/t/dsp-running-under-nginx/161/13 "2014-08-21T06:23:26Z")

</div>

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](https://github.com/dreamfactorysoftware/dsp-core/blob/develop/config/external/nginx/etc/nginx/sites-available/dsp.multi.local)) defines two server clauses. One for **http** , and one for **https**.

The second ([dsp.single.local](https://github.com/dreamfactorysoftware/dsp-core/blob/develop/config/external/nginx/etc/nginx/sites-available/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!

---

<div class="post-metadata">

**Author:** ![erick](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/erick/32/335_2.png) [@erick](https://community.dreamfactory.com/u/erick)\
**Post date:** [July 16, 2015, 2:10am UTC](https://community.dreamfactory.com/t/dsp-running-under-nginx/161/14 "2015-07-16T02:10:57Z")

</div>

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

Also SSLv3 should be removed. (POODLE)

---

<div class="post-metadata">

**Author:** ![jeffreystables](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/jeffreystables/32/173_2.png) [@jeffreystables](https://community.dreamfactory.com/u/jeffreystables)\
**Post date:** [July 20, 2015, 6:07pm UTC](https://community.dreamfactory.com/t/dsp-running-under-nginx/161/15 "2015-07-20T18:07:38Z")

</div>

[This SF post](http://serverfault.com/questions/67316/in-nginx-how-can-i-rewrite-all-http-requests-to-https-while-maintaining-sub-dom) appears to be an accepted answer on how to force HTTPS in Nginx.
