0

I'm working on a small react login modal. The problem I'm facing is that when I use axios.post('/login', { username, password }) I just get a generic nginx error from ddev (https://github.com/drud/docker.nginx-php-fpm-local/blob/master/files/usr/share/nginx/html/40x.html)

I checked both php-fpm and nginx logs without any useful information.

I have no idea what may be the issue, but follows the config file in use:

map $http_x_forwarded_proto $fcgi_https {
    default off;
    https on;
}

server {
    listen 80;
    listen [::]:80 default ipv6only=on;

    root $NGINX_DOCROOT/public;

    index index.php index.htm index.html;

    server_name _;

    sendfile off;
    error_log /var/log/nginx/error.log info;
    access_log /var/log/nginx/access.log;

    location / {
        absolute_redirect off;
        try_files $uri $uri/ /index.php?q=$uri&$args;
    }

    location ~ \.php$ {
        try_files try_files $uri $uri/ /index.php$is_args$args;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/run/php-fpm.sock;
        fastcgi_buffers 16 16k;
        fastcgi_buffer_size 32k;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param SCRIPT_NAME $fastcgi_script_name;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_intercept_errors on;
        # fastcgi_read_timeout should match max_execution_time in php.ini
        fastcgi_read_timeout 10m;
        fastcgi_param SERVER_NAME $host;
        fastcgi_param HTTPS $fcgi_https;
    }

    location ~* \.(?:rss|atom)$ {
        expires 1h;
    }

    location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
        expires 1M;
        access_log off;
        add_header Cache-Control "public";
    }

    location ~* /\.(?!well-known\/) {
        deny all;
    }

    location ~* (?:\.(?:bak|conf|dist|fla|in[ci]|log|psd|sh|sql|sw[op])|~)$ {
        deny all;
    }

    location ^~ /system/files/ {
        log_not_found off;
        access_log off;
        expires 30d;
        try_files $uri @rewrite;
    }

    location /healthcheck {
        access_log off;
        stub_status     on;
        keepalive_timeout 0;    # Disable HTTP keepalive
        return 200;
    }

    error_page 400 401 /40x.html;
    location = /40x.html {
            root   /usr/share/nginx/html;
    }

    location ~ ^/(fpmstatus|ping)$ {
        access_log off;
        stub_status     on;
        keepalive_timeout 0;    # Disable HTTP keepalive
        allow 127.0.0.1;
        allow all;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        fastcgi_pass unix:/run/php-fpm.sock;
    }
}

Thanks in advance!

SidFerreira
  • 551
  • 3
  • 20
  • 1
    Does this happen when you use Postman or SoapUI (or any other cliient) as well? – c-chavez Aug 29 '18 at 23:41
  • After digging a lot, I found out that removing the header 'Content-Type: application/json;charset=UTF-8' it works... @c-chavez I don't have any of those setup – SidFerreira Aug 30 '18 at 00:41

2 Answers2

1

The problem was:

error_page 400 401 /40x.html;
location = /40x.html {
        root   /usr/share/nginx/html;
}

commenting this block fixed it.

SidFerreira
  • 551
  • 3
  • 20
  • So are you saying that your application requires nginx *not* to handle the 400 errors? Should this be done differently? – rfay Sep 24 '18 at 17:53
  • 1
    @rfay Basically, my application handles the 404. – SidFerreira Sep 28 '18 at 13:26
  • 1
    It's an interesting problem, because there's not a straightforward way to override that behavior with the web container currently. But I'm not sure a PHP app would normally be in charge of 40x? If so, we should probably remove that. The idea of having that block was to give clear feedback to the user about a 40x, which is most commonly handled by the webserver. But maybe it should be pulled. – rfay Sep 29 '18 at 16:55
  • 1
    That snippet has been removed in ddev v1.8.0, so the web container nginx no longer tries to handle 40x. – rfay May 14 '19 at 22:16
  • @rfay place it as an answer so I can mark it as the correct one – SidFerreira May 15 '19 at 12:22
1

This should work without issues starting with ddev v1.8.0, as the offending nginx 40x handling was removed in https://github.com/drud/ddev/pull/1555 - Thanks for the community PR @AronNovak.

rfay
  • 9,963
  • 1
  • 47
  • 89