3

Apologies, I know this is a basic question, but I'm learning nginx!

I've inherited a Nginx driven site, the problem is that when browsing to a specific php file it initiates a download.

The file, extload.php, is meant to handle a return POST request from a payment gateway but it's throwing a 405 when it's POST'd to.

The index.php on the site gets executed correctly when GET'd (it is in a different directory), so it seems to be just this specific file that's an issue.

what I think are the relevant lines from nginx.conf are below, extload.php is referenced at the bottom, presumably there's something I need to change there?

index index.html index.php;

upstream fastcgi_backend {
    server unix:/var/run/php/php5.6-fpm.sock;
}

server {
  listen 80;
  listen [::]:80;

server_name staging.mysite.com;

location /RequestDenied {
  return 444;
}

if ($redirected_url != "none") {
  rewrite ^ $redirected_url permanent;
}

return 301 https://staging.mysite.com$request_uri;
}

server {
  listen 443 ssl http2;
  listen [::]:443 ssl http2;

  server_name staging.mysite.com;

  ssl_certificate /etc/letsencrypt/live/staging.mysite.com/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/staging.mysite.com/privkey.pem;
  ssl_session_cache shared:SSL:10m;
  ssl_session_timeout 10m;

  add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";

  if ($redirected_url != "none") {
    rewrite ^ $redirected_url permanent;
  }

  root /var/www/current/default_site;

  if ($request_uri ~* "^(.*/)index\.php(/?)(.*)") {
    return 301 $1$3;
  }

  set $request_url "$scheme://$http_host$request_uri";

  if ($request_url = $http_referer) {
    set $request_is_referer 1;
  }

  location ~ ^/(static|assets|themes|media|images|Content|100assets)/ 
  {
    access_log off;

    location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ {
      add_header Cache-Control "public";
      add_header X-Frame-Options "SAMEORIGIN";
      expires +1y;
    }

    location ~* \.(zip|gz|gzip|bz2|csv|xml)$ {
      add_header Cache-Control "no-store";
      add_header X-Frame-Options "SAMEORIGIN";
      expires off;
    }
  }

  location / {
    try_files $uri $uri/ /index.php?$args;

    #include /etc/nginx/naxsi.rules;
  }

  location ~ ^/(index|admin)\.php$ {
    limit_req zone=bots;

    try_files $uri =404;
    fastcgi_pass fastcgi_backend;
    fastcgi_buffers 1024 4k;

    fastcgi_read_timeout 600s;
    fastcgi_connect_timeout 600s;

    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

    fastcgi_param DEBUG "True";
    fastcgi_param CACHE "True";
    fastcgi_param MAINTENANCE "False";

    fastcgi_param mysite_DOMAINS_MAIN "staging.mysite.com";

    include fastcgi_params;

    #include /etc/nginx/naxsi.rules;
  }

  location /RequestDenied {
    return 444;
  }

  location ~* (\.php$|\.phtml$|\.htaccess$|\.git) {
    deny all;
  }

  location = /assets/addons/cartthrob/lib/extload.php {
          allow all;
  }
}
  • Do you have a firewall or other site protection application installed? Cheers!! – closetnoc Sep 26 at 14:12
  • There is a firewall, but there doesn't seem to be many rules, what should I look for? – tester Sep 26 at 15:12
  • I don't know specifically, however, I did find this page which suggested that the firewall was the problem. ipfs-sec.stackexchange.cloudflare-ipfs.com/expressionengine/A/… Cheers!! – closetnoc Sep 26 at 15:14
  • Thanks, but that refers to a 403 error, so I don't think is the answer – tester Sep 26 at 15:17
  • Ooopppsss! My bad!! I must have gone cross-eyed. I will get another cup of coffee and try again later. Cheers!! – closetnoc Sep 26 at 16:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.