0

What I'd like: I want to have the laravel site show unless it's for /writing. In that case I want it to proxy pass anything in that subdirectory to a nodejs site.

What happens: The laravel site catches the request and says it can't find the requested route instead of allowing the Node site to show up there. The Node site won't show up at all via this config

I'm trying to get a website (php, specifically laravel), that uses rewrite to work while also using another site (nodejs) at the sub directory /writing.

I've been going between redirect loops and laravel catching the request instead and nothing I've found seems related to what I've done and doesn't give me advice on how to properly fix my structure here if that is the problem.

server {
    listen  80; ## listen for ipv4; this line is default and implied
    server_name .domain.tld;

    root /var/www/vhosts/domain/public;
    index index.php index.html index.htm;

    location /writing/ {
            proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
            #proxy_set_header   X-Real-IP $remote_addr;
            proxy_set_header   Host      $http_host;
            proxy_set_header   X-Forwarded-Proto $scheme;
            proxy_pass         http://127.0.0.1:xxxx;
            proxy_redirect off;
        }   

    location / {
        try_files $uri $uri/ /index.html;
    }

    # Removes trailing slashes
    if (!-d $request_filename) {
        rewrite ^/(.+)/$ /$1 permanent;
    }

    # Rewrite to index.php unless the request is for an existing file (image, js, css, etc.)
    if (!-e $request_filename) {
        rewrite ^/(.*)$ /index.php?/$1 last;
        break;
    }

    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /usr/share/nginx/www;
    }
    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

    location ~ \.php$ {
        try_files $uri /index.php =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one

    location ~ /\.ht {
        deny all;
    }

}
cmp
  • 101
  • 2

0 Answers0