0

I have what I believe is a fairly standard fastcgi/php5-fpm setup using Unix socks, and the configuration file for my website (excuse the find&replace) is the following:

server {
    listen 80;
    server_name example.com www.example.com;

    access_log /srv/vhost/sites/example/logs/access.log;
    error_log /srv/vhost/sites/example/logs/error.log;

    root /srv/vhost/sites/example/public_html;
    index index.php index.html index.htm;

    location / {
        index index.php;
        try_files $uri $uri/ @wikka;
    }

    location @wikka {
        rewrite ^(.*/[^\./]*[^/])$ $1/ last;
        rewrite ^(.*)$ /wikka.php?wakka=$1 last;
    }


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

      fastcgi_split_path_info ^(.+\.php)(/.+)$;

      include fastcgi_params;
      fastcgi_param  SCRIPT_FILENAME /srv/vhost/sites/example/public_html$fastcgi_script_name;
      fastcgi_index  index.php;
      fastcgi_pass   unix:/etc/nginx/sockets/example.sock;
    }
}

I cannot seem to ever get it to rewrite /xxx to wikka.php?wakka=xxx.

I usually always get 502 BAD GATEWAY on these rewrite attempts, and the logs show nearly the same thing each time:

[error] 19289#0: *6 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 174.1.235.8, server: example.com, request: "GET /Home HTTP/1.1", upstream: "fastcgi://unix:/etc/nginx/sockets/example.sock:", host: "example.com"

Do you know what can be happening? Do you know how to rewrite the simple example as above in nginx? It appears people have asked for similar information (WikkaWiki is the name, here: nginx rewrite for wikkawiki but were not successful)

I've tried various @locations, or adding the rewrite to various places with last; or break; at the end often ending up in redirect loops.

I always upload the new configuration and SIGHUP (or restart via init.d) nginx, and before test with nginx -t to ensure it is at least valid if you require that information.

1
  • Are you sure PHP-FPM is up & running & available through the unix socket? 502 sometimes arise when backend is not available. Feb 20, 2012 at 10:06

1 Answer 1

-1

Try recopying everything inside the Location ~ .php block into Location @wikka block.

1
  • Link-only answers are strongly discouraged. Please edit your answer and post content here, linking to external sources if needed.
    – EEAA
    Feb 3, 2013 at 3:56

You must log in to answer this question.

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