1

The problem started when I noticed that angular failed to load with net::ERR_CONTENT_LENGTH_MISMATCH.

Full list of errors:

GET http://xyx.com/assets/angular/angular.js?body=1 net::ERR_CONTENT_LENGTH_MISMATCH
Uncaught ReferenceError: angular is not defined(anonymous function) @ angular-cookie.js?body=1:7
Uncaught ReferenceError: angular is not defined(anonymous function) @ ui-bootstrap-tpls.js?body=1:9
Uncaught TypeError: Cannot read property 'isDefined' of undefined(anonymous function) @ angular-ui-router.js?body=1:19(anonymous function) @ angular-ui-router.js?body=1:4340
Uncaught ReferenceError: angular is not defined(anonymous function) @ ng-optimizely.js?body=1:1
Uncaught TypeError: Cannot read property '$$minErr' of undefined(anonymous function) @ angular-resource.js?body=1:9(anonymous function) @ angular-resource.js?body=1:628
Uncaught ReferenceError: angular is not defined

I did some research which lead me to check the nginx error log. The log produced the following error:

2015/11/11 16:26:31 [crit] 39125#0: *255 open() "/usr/local/var/run/nginx/proxy_temp/4/00/0000000004" failed (13: Permission denied) while reading upstream, client: x.x.x.x, server: xyx.com, request: "GET /assets/angular/angular.js?body=1 HTTP/1.1", upstream: "http://x.x.x.x:9090/assets/angular/angular.js?body=1", host: "xyz.com", referrer: "url_here"

I found a post that had a similar issue. However, deleting the contents of the /usr/local/var/run/nginx directory and restarting nginx did not solve the problem.

I also verified that the nginx worker process was being run by the same owner of the /usr/local/var/run/nginx/proxy_temp directory, as mentioned in another post (user is nobody). Changing permissions to 777 didn't work either.

This problem is occurring in my Dev environment. I'm using a Mac with El Capitan (10.11.1) and nginx version 1.8.0. Any assistance with this would be greatly appreciated.

nginx config file:

server {
  listen 80;

  server_name www.local.site.com;
  return 301 https://local.site.com$request_uri;
}

server {
  listen 80;
  server_name local.sell.site.com;

  location / {
    proxy_pass http://x.x.x.x:9090;
  }
}

server {
  listen 443;
  server_name local.sell.site.com;

  ssl on;
  ssl_certificate /Users/sheldon/Repos/site/config/nginx/ssl/site.crt;
  ssl_certificate_key /Users/sheldon/Repos/site/config/nginx/ssl/site.key;
  ssl_session_timeout  5m;
  ssl_protocols  TLSv1 TLSv1.1 TLSv1.2;
  ssl_ciphers "[Removed]";
  ssl_prefer_server_ciphers on;


  location / {
    proxy_pass http://x.x.x.x:9090;
  }
}

server {
  listen 443;

  root /Users/sheldon/Repos/site/www;
  index index.php;
  server_name local.site.com;
  access_log /Users/sheldon/logs/nginx/local.site.com.access.log;
  error_log /Users/sheldon/logs/nginx/local.site.com.error.log;

  ssl on;
  ssl_certificate /Users/sheldon/Repos/site/config/nginx/ssl/site.crt;
  ssl_certificate_key /Users/sheldon/Repos/site/config/nginx/ssl/site.key;
  ssl_session_timeout  5m;
  ssl_protocols  TLSv1 TLSv1.1 TLSv1.2;
  ssl_ciphers "[Removed]";
  ssl_prefer_server_ciphers on;

  large_client_header_buffers 4 8m;

  location ~* (.+)\.(\d+)\.(js|css|png|jpg|jpeg|gif)$ {
    try_files $uri $1.$3;
  }

  location / {
      index index.html index.php;
      try_files $uri $uri/ @handler;
      expires 30d;
  }

  location ^~ /media/downloadable/ { deny all; }

  location  /. {
      return 404;
  }

  location @handler {
      rewrite / /index.php;
  }

  location ~ .php/ {
      rewrite ^(.*.php)/ $1 last;
  }

  location ~ \.php$ {
      if (!-e $request_filename) {
      rewrite / /index.php last;
      }
      expires off;
      fastcgi_split_path_info ^(.+\.php)(/.+)$;
      fastcgi_pass unix:/tmp/php5-fpm.sock;
      fastcgi_index index.php;
      fastcgi_intercept_errors on;
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      fastcgi_param MAGE_RUN_TYPE store;
      fastcgi_param ENVIRONMENT dev;
      fastcgi_param MAGE_IS_DEVELOPER_MODE true;
      fastcgi_buffer_size 128k;
      fastcgi_buffers 4 256k;
      fastcgi_busy_buffers_size 256k;
      fastcgi_read_timeout 420;
      include fastcgi_params;
  }

  location /api { 
      rewrite ^/api/rest /api.php?type=rest; 
  }
}
Community
  • 1
  • 1

1 Answers1

0

You have also to give enough permission to the user under which nginx is running to the directory that is hosting your upstream http://x.x.x.x:9090 and having your deployed source code.

Muhammad Soliman
  • 21,644
  • 6
  • 109
  • 75
  • I'm running nginx locally and have just tried changing all the files and directories in my repo that contains the source code for this project to the nobody user. After doing this and restarting nginx, I'm still having the same issue. Do you have any idea what else could be wrong? – Sheldon Martin Nov 12 '15 at 15:25
  • would u plz share the configuration file of ur nginx .. u could put it in the question body itself – Muhammad Soliman Nov 13 '15 at 07:44
  • I've added the nginx config for the site in question. Please take a look when you have time. @msoliman – Sheldon Martin Nov 13 '15 at 18:52
  • where is http://x.x.x.x:9090 is hosted in the same machine or different machine ? .. could u access this URL from current machine that is having installed version of nginx – Muhammad Soliman Nov 15 '15 at 12:11
  • this x.x.x.x:9090 should be real IP address . if you are hosting ur behind backend server in the same machine make it http://127.0.0.1:9090 otherwise specify the real IP – Muhammad Soliman Nov 15 '15 at 12:13
  • It is being hosted on the same machine and the IP is set to 127.0.0.1:9090. I just removed any IPs to be on the safe side. Sorry if this caused any confusion. – Sheldon Martin Nov 16 '15 at 14:50
  • now plz go to the root directory hosting this site (127.0.0.1:9090) and do the following commands >>> sudo chown -R www-data dir_9090 >>> sudo chmod -R 777 dir_9090 >>> sudo service nginx restart >>> RESTART SERVER BEHIND THAT'S HOSTING 9090 port too .. then update if the issue still exists – Muhammad Soliman Nov 17 '15 at 06:15
  • Thanks a lot for your help so far. Unfortunately I don't have a www-data user on my machine. The nobody user runs the nginx worker process, and I tried running your commands with the nobody user, and it didn't work. Perhaps a different user is in charge of the task you assume www-data is doing on my machine. Could you tell me what the www-data user is responsible for? So that I might figure out which user it is on my machine. – Sheldon Martin Nov 19 '15 at 18:04
  • Actually you have to grant permission to the user under which nginx is running to access site's directory. you could find that user inside your nginx.conf that's usually found /etc/nginx/ .. it might be even different user than 'www-data' I think the default user is named "nginx" .. if so grant the access to that user to allow read/write to the site's directory – Muhammad Soliman Nov 21 '15 at 13:19