How to config nginx (Front end proxy for apach) for Xenforo?

October 18, 2014 1.6k views

I can't connect to proxy of apache2 for nginx to config Friendly URLs fo XenForo,
This is my content in sites-enabled of nginx

      server {
        listen  80;
        server_name domain.com www.domain.com;
        root /var/www/bundle;
        index index.php index.html index.htm;
        #access_log  /var/www/logs/domain.access.log;
        location / {
        try_files $uri $uri/ /index.php?$uri&$args;
        index index.php index.html;
        proxy_pass http://127.0.0.1:8080/;
        #allow 1.1.1.1 ;
    }
        location ~ /(internal_data|library) {
         internal;
       #proxy_pass http://127.0.0.1:8080;
    }
        location ~ \.php$ {
        fastcgi_pass   127.0.0.1:8080;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include fastcgi_params;
        #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;
       # }
}

and content in sites-available of Apache2

    <VirtualHost 127.0.0.1:8080>
    ServerName domain.com
    ServerAlias www.domain.com
    DocumentRoot /var/www/bundle
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
 <Directory /var/www/bundle/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>
    </VirtualHost> 

Please help !!!... Thank you ..

1 Answer

I don't have any experience with Xenforo, so I'm not entirely sure what you mean by "friendly URLs." If you could explain further, we might be able to help you better. Though more generally, there are some issues with the way that you have set up your reverse proxy. For instance, you don't need to set up anything dealing with fastcgi as the proxy pass should be sending the php file to Apache to be interpreted.

Your Nginx configuration should look something like:

server {
        listen   80; 

        root /var/www/bundle; 
        index index.php index.html index.htm;

        server_name example.com; 

        location / {
            try_files $uri $uri/ /index.php;
        }

        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;
        }
}

The Apache configuration look pretty good. Remember to change Listen 80 to Listen 8080 in /etc/apache2/ports.conf as well.

Let us know how it goes!

Have another answer? Share your knowledge.