1

I'm using Nginx as a proxy with Apache2 behind it. The current config works and I can access the site. However, the PHP application is build on Zend Framework 2 and relies on urls in /controller/action/ structure and these does not get passed to Apache2. This results that every link from the homepage to subpages is broken and redirects to our "Page not found"-page. The url passed to Apache2 is /index.php instead of /controllerX/actionY

Nginx (VirtualHost) config

server {
    listen 80;

    root /var/www/talentina_dev/talentina-alpha-temp/public/;
    index index.php index.html index.htm;
    server_name dev-aws.talentina.com;

    location / {
            try_files $uri $uri/ /index.php;
            proxy_set_header X-Real-IP  $remote_addr;
            proxy_set_header X-Forwarded-For $remote_addr;
            proxy_set_header Host $host;
            proxy_pass http://127.0.0.1:8080;

    }

    location ~ \.php$ {
            proxy_set_header X-Real-IP  $remote_addr;
            proxy_set_header X-Forwarded-For $remote_addr;
            proxy_set_header Host $host;
            proxy_pass http://127.0.0.1:8080;
    }

    location ~ /\.ht {
            deny all;
    }
}

A requirement is that the initial url is "/" to get to the homepage and I think it's covered with the location / {..} structure. However, since I'm very new to this, I'm open to suggestions.

Big thanks in advance !

UPDATE Adding VirtualHost file from Apache2

<VirtualHost 127.0.0.1:8080>
    ServerAdmin ...
    ServerName dev-aws.talentina.com
    ServerAlias dev-aws.talentina.com
    DocumentRoot /var/www/talentina_dev/talentina-alpha-temp/public/
    php_value error_reporting 6135
    <Directory />
            Options FollowSymLinks
            AllowOverride All
    </Directory>
    <Directory /var/www/talentina_dev/talentina-alpha-temp/public>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
    </Directory>
</VirtualHost>

1 Answer 1

3

Try_files line brake urls. You do not need it with proxy - remove it. And you probably do not need this block too:

location ~ \.php$ {
        proxy_set_header X-Real-IP  $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $host;
        proxy_pass http://127.0.0.1:8080;
5
  • Thanks for the answer, I think it's a step in the right direction. However, I am now getting the Page Not Found error directly from Apache2. I think this implies that index.php is not called to process the controller/action.
    – Gnagy
    Dec 12, 2013 at 12:06
  • That probably will need some rewrite in apache. Dec 12, 2013 at 12:08
  • I have added the VirtualHost config to the question. Perhaps you could take a look at it if it's correct to cooperate with Nginx ? thanks
    – Gnagy
    Dec 12, 2013 at 12:14
  • You probably need to add all location part of example config: framework.zend.com/manual/1.12/en/… Dec 12, 2013 at 12:17
  • Thanks, the rewrite is already handled by the .htaccess, the rewrite module wasnt enabled on the fresh Apache2 installation.
    – Gnagy
    Dec 12, 2013 at 12:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .