0

I'm trying to set up an nginx server to serve a node.js application at myurl.com, while at the same time serve some php-content from myurl.com/phpapp/

I had the php application working with proxy using fastcgi_pass. But when i started configuring the proxying for the node.js application it broke the proxying to the php-app.

Both the apps are found in their own catalogs in the root directory.

As far as I can tell from http://wiki.nginx.org/HttpCoreModule#location it really shouldn't be more to it than defining a location /phpapp/.*.php and do the fastcgi_pass from there, no?

But i can't get it to work. My nginx access.log tells me it can't find the files

"GET /sqlbuddy/js/movement.js/?ver=1_3_3 HTTP/1.1" 404 774 "http://192.168.0.174/sqlbuddy/login.php"

the login page shows, but without the styling. Also, it doesn't work when i try to login, just returns to the same page.

I tried creating a sub domain, something like phpapp.myurl.com and serve the php from there, but i ran in to some url conflicts and honestly didn't spend that much time trying to make it work..

After banging my head against the wall for the last couple of days i'm not even sure this is possible any longer? Do i have to break out the phpapp to another subdomain?

here is my current conf file

server {
    listen   80; ## listen for ipv4; this line is default and implied

    root /usr/share/nginx/html;
    index index.html index.htm index.php;

    # Make site accessible from http://localhost/
    server_name localhost myurl.com

    location ~*/sqlbuddy/.\*.php{
            try_files $uri $uri/ =404;
            allow 192.168.0.0/24;
            allow 127.0.0.1;
            deny all;
            include fastcgi_params;
            fastcgi_pass php5-fpm-sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_intercept_errors on;
    }
   location ~\.php$ {
            try_files $uri =404;
            allow 192.168.0.0/24;
            allow 127.0.0.1;
            deny all;       
            include fastcgi_params;
            fastcgi_pass php5-fpm-sock;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_intercept_errors on;
    }


    location / {
            allow 192.168.0.0/24;
            allow 127.0.0.1;
            proxy_pass      http://127.0.0.1:2368;
            proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_redirect default;
    }

    location  /ghost/ {
            allow 192.168.0.0/24;
            allow 127.0.0.1;
            deny all;

            proxy_set_header Host           $http_host;
            proxy_set_header X-Real-IP      $remote_addr;
            proxy_pass      http://127.0.0.1:2368;
            proxy_redirect default;
    }

}

When sqlbuddy was working properly, the root location was completely empty.

Any pointers would be appreciated. Thanks!

1
  • What's do you put in location / before adding node.js proxy configuration? (in other words, please post your working configuration for this site before adding node.js proxy config)
    – masegaloeh
    May 18, 2014 at 15:09

1 Answer 1

0

Read the nginx location documentation again. Try this:

location ^~ /sqlbuddy/.*\.php {

Or, maybe:

location ~* ^/sqlbuddy/.*\.php {

The spaces are important!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .