2011-11-28 14 views
6

Estoy tratando de usar ResourceSpace como un alias en Nginx. Los scripts de página se cargan bien pero los archivos estáticos no se cargan. El acceso a los subdirectorios da un error de undefined indexNginx que sirve un directorio como alias

cargas eximmanger con todos los scripts más archivos estáticos mientras ResourceSpace no se puede cargar archivos estáticos, cargar sólo los guiones

Ésta es mi config

server { 
    listen 80; 
    server_name myserver.com www.myserver.com; 
    server_name_in_redirect off; 

    access_log /var/log/nginx/myserver.access_log main; 
    error_log /var/log/nginx/myserver.error_log info; 

    location /resourcespace { 
     alias /var/www/html/ResourceSpace/; 

    } 


    location /eximmanager { 
     alias /var/www/html/exim4u/exim4u/; 

    } 

    location /100/ { 
      rewrite^http://100.myserver permanent; 

    } 




    location ~ ^/eximmanger/(.+\.*)$ { 
     alias /var/www/html/exim4u/exim4u/$1; 
     fastcgi_pass unix:/tmp/php.socket; 
     fastcgi_index index.php; 
     fastcgi_param SCRIPT_FILENAME $request_filename; 

     # From fastcgi_params 
fastcgi_param QUERY_STRING  $query_string; 
fastcgi_param REQUEST_METHOD  $request_method; 
fastcgi_param CONTENT_TYPE  $content_type; 
fastcgi_param CONTENT_LENGTH  $content_length; 
fastcgi_param SCRIPT_NAME  $fastcgi_script_name; 
fastcgi_param REQUEST_URI  $request_uri; 
fastcgi_param DOCUMENT_URI  $document_uri; 
fastcgi_param DOCUMENT_ROOT  /var/www/html/exim4u/exim4u; # <-- Changed 
fastcgi_param SERVER_PROTOCOL $server_protocol; 
fastcgi_param GATEWAY_INTERFACE CGI/1.1; 
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; 
fastcgi_param REMOTE_ADDR  $remote_addr; 
fastcgi_param REMOTE_PORT  $remote_port; 
fastcgi_param SERVER_ADDR  $server_addr; 
fastcgi_param SERVER_PORT  $server_port; 
fastcgi_param SERVER_NAME  $server_name; 
fastcgi_param REDIRECT_STATUS 200; 
    } 


    location ~ ^/resourcespace/(.+\.*)$ { 
     alias /var/www/html/ResourceSpace/$1; 
     fastcgi_pass unix:/tmp/php.socket; 
     fastcgi_index index.php; 
     fastcgi_param SCRIPT_FILENAME $request_filename; 

     # From fastcgi_params 
fastcgi_param QUERY_STRING  $query_string; 
fastcgi_param REQUEST_METHOD  $request_method; 
fastcgi_param CONTENT_TYPE  $content_type; 
fastcgi_param CONTENT_LENGTH  $content_length; 
fastcgi_param SCRIPT_NAME  $fastcgi_script_name; 
fastcgi_param REQUEST_URI  $request_uri; 
fastcgi_param DOCUMENT_URI  $document_uri; 
fastcgi_param DOCUMENT_ROOT  /var/www/html/ResourceSpace; # <-- Changed 
fastcgi_param SERVER_PROTOCOL $server_protocol; 
fastcgi_param GATEWAY_INTERFACE CGI/1.1; 
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; 
fastcgi_param REMOTE_ADDR  $remote_addr; 
fastcgi_param REMOTE_PORT  $remote_port; 
fastcgi_param SERVER_ADDR  $server_addr; 
fastcgi_param SERVER_PORT  $server_port; 
fastcgi_param SERVER_NAME  $server_name; 
fastcgi_param REDIRECT_STATUS 200; 
    } 


    root /var/www/html/myserver; 
    index index.php; 
    # Support Clean (aka Search Engine Friendly) URLs 
    location/{ 
      try_files $uri $uri/ /index.php?q=$request_uri; 
    } 

    index index.php index.html index.htm default.html default.htm; 
    # deny running scripts inside writable directories 
    location ~* /(images|cache|media|logs|tmp)/.*\.(php|pl|py|jsp|asp|sh|cgi)$ { 
      return 403; 
      error_page 403 /403_error.html; 
    } 



    location ~ .*.php$ { 
     #include /etc/nginx/fastcgi_params; 
     fastcgi_pass unix:/tmp/php.socket; 
     fastcgi_index index.php; 
     include fastcgi_params; 
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 


    } 

    # caching of files 
    location ~* \.(ico|pdf|flv)$ { 
      expires 1y; 
    } 

    location ~* \.(js|css|png|jpg|jpeg|gif|swf|xml|txt)$ { 
      expires 14d; 

Respuesta

2

descubrí que el problema no estaba relacionado con nginx en absoluto, sino con la directiva ResourceSpace $baseurl. En la directiva había mezclado $baseurl = 'http://resourcespace.myserver.com'; y $baseurl = 'http://myserver.com/resourcespace';. Así que ten cuidado con eso si tienes problemas similares.

Cuestiones relacionadas