Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

we have two nginx servers. The first server receives a request via www.example.com/partner. He sends the whole request to the second server which has php+fastCgi configured. Nginx access log from second server:

"GET /partner/ HTTP/1.0" 200 2845

On the second server I have a vhost that looks like that:

server {
       listen my.ip:80;
       server_name www.example.com;
       root /var/www/example;

       if ($http_host != "www.example.com") {
                 rewrite ^ http://www.example.com$request_uri permanent;
       }

       index index.php index.html;


       location = /partner/favicon.ico {
                log_not_found off;
                access_log off;
                expires max;
       }


        location @nocache {
                try_files $uri $uri/ /index.php?$args;
       }
       location = /partner/robots.txt {
                allow all;
                log_not_found off;
                access_log off;
       }

       location ^~ /partner/typo3temp/tx_ncstaticfilecache {
                expires 43200;
                charset utf-8;
       }

       location = /partner/clear.gif {
                empty_gif;
                expires max;
       }
       location ^~ /partner/typo3/gfx {
                expires max;
       }
       location ^~ /partner/typo3temp/compressor {
                expires max;
       }   

    location /partner {    


                if ($query_string ~ ".+") {
                        return 405;
                }
                # pass requests from logged-in users to PHP
                if ($http_cookie = 'nc_staticfilecache|be_typo_user' ) {
                        return 405;
                } # pass POST requests to PHP
                if ($request_method !~ ^(GET|HEAD)$ ) {
                        return 405;
                }
                if ($http_pragma = 'no-cache') {
                        return 405;
                }
                if ($http_cache_control = 'no-cache') {
                        return 405;
                }
                error_page 405 = @nocache;

                # serve requested content from the cache if available, otherwise pass the request to PHP
                try_files /typo3temp/tx_ncstaticfilecache/$host${request_uri}index.html @nocache;


       location ~* \.(sql|htaccess|htpasswd|tpl|html5|xhtml) {
                deny all;
       }

       location ~*  \.(jpg|jpeg|png|gif|css|js|ico)$ {
                expires max;
                log_not_found off;
       }

       location ~* \.(cur|ico|gif|png|jpe?g|css|js|swf|woff)((\?\d\d\d\d\d\d\d\d\d\d)|(\?s=\d\d\d\d\d\d\d\d\d\d))$ {
                expires max;
                log_not_found off;
       }
       location ~* \.(cur|ico|gif|png|jpe?g|css|js|swf|woff)(\?v\d\d?\.\d\d?\.\d\d?)$ {
                expires max;
                log_not_found off;
       }
       location ~* ^(/typo3/sysext|/typo3conf/ext).*\.(cur|ico|gif|png|jpe?g|css|js|swf|woff) {
                expires max;
                log_not_found off;
       }



       location ~ /\. {
                deny all;
                access_log off;
                log_not_found off;
       }

       location ~ \.php$ {
                try_files $uri =404;
                include /etc/nginx/fastcgi_params;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_index index.php;
       }
    }
}

The problem that the index.php is not interpreted, instead it is downloaded. Any ideas whats wrong?

share|improve this question
    
You forgot a semicolon at server_name. –  Sašo Apr 24 '12 at 20:45
add comment

1 Answer

up vote 2 down vote accepted
+50

Your configuration is pretty similar to this one, part you obviously missing is try_files $uri $uri/ /index.php?$args; in the root of the server block.

Another suggest is to try to use configuration exactly like from the link to make sure everything is working and it's not caused by your location / ifs. After that include error_log ~/nginx_debug.log info; in the server block and make your changes - you'll be able to understand which part of your configuration is broken.

share|improve this answer
    
the config is acutally from here howtoforge.com/… –  ArtWorkAD Apr 25 '12 at 6:54
    
I dont really get it why there is all that wordpress stuff in your config... –  ArtWorkAD Apr 25 '12 at 7:30
    
As I said I got typo3 working so far. But I want it to be accessable from my-site.com/partner. But I always get 404 error. With the config that I posted typo3 works great for a subdomain e.g. typo3.my-site.com... –  ArtWorkAD Apr 25 '12 at 9:53
    
no ^-^ do you mean I have to change all location / ? –  ArtWorkAD Apr 25 '12 at 10:11
    
hm the ^~ /partner thing does not seem to work either –  ArtWorkAD Apr 25 '12 at 12:38
show 6 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.