problems with mediawiki behind nginx / apache (redirects to wrong url)

Gelonida N gelonida at gmail.com
Sun Sep 11 18:44:58 UTC 2011


I have now a working (perhaps not optimized) solution.


1.) Add following variable to Mediawiki's LocalSettings.php:
$wgServer = 'https://servername';

I found this tip finally at
http://www.cyberciti.biz/faq/mediawiki-fix-internal-server-host-names-redirect-using-wgserver/

though they specify the entire server url with the path to the wiki,
whereas I specify just the protocol and the server



2,) As Mediawiki urls look like:
https://servername/wiki/index.php/blablabla
I have to be sure, that all these urls get redirected to apache

this I changed my setup to:

    location ~ \.(php)$ {
        include proxy.conf;
        proxy_pass         http://127.0.0.1:8081;
    }

    location /wiki/index.php {
        include proxy.conf;
        proxy_pass         http://127.0.0.1:8081;
    }

    location / {
        root   /home/noma/web/nomassl;
        index  index.html index.htm index.php;
    }



Perhaps this post can help somebdoy else. I was searching for quite some
time and was already close to giving up.

On 09/11/2011 08:13 PM, Gelonida N wrote:
> Hi,Well I have finally a (non optimized) setting, which is working.


On 09/11/2011 08:13 PM, Gelonida N wrote:
> Hi,
> 
> I'm having a little trouble to get Mediawiki working in my nginx setup.
> 
> The problem is very probably the configuration of Mediawiki, but the
> Help pages about Mediawiki don't mention nginx.
> So I thought I ask here.
> 
> 
> My Problem:
> - I setup nginx with https such, that it handles all files, except php
> files, which fill be proxied to apache/mod_php at port 8081
> 
> - I installed a new Mediawiki
> 
> - the installation via the web worked fine and was confirmed
>     with a success message
> 
> - then I moved config/LocalSedttings.php  to the wiki directory
> 
> Now I access https:/servername/wiki2/
> and get redirected to http://servername:8081/wiki2/index.php/Main_Page
> 
> 
> Below my nginx configuration:
> 
> 
> # ============== nginx configuration ========
> server {
>     listen       443 ssl;
>     ssl_session_timeout  10m;
>     ssl_session_cache    shared:SSL:10m;
> 
>     location ~ \.(php)$ {
>         include proxy.conf;
>         proxy_pass         http://127.0.0.1:8081;
>     }
> 
>     # nginx shall serve all files except the php ones
>     location / {
>         root   /my/doc/root;
>         index  index.html index.htm index.php;
>     }
> 
> # ==================== proxy.conf ==============
> proxy_redirect     off;
> 
> proxy_set_header   Host             $host;
> proxy_set_header   X-Real-IP        $remote_addr;
> proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
> 
> client_max_body_size       10m;
> client_body_buffer_size    128k;
> 
> proxy_connect_timeout      90;
> proxy_send_timeout         90;
> proxy_read_timeout         90;
> 
> proxy_buffer_size          4k;
> proxy_buffers              4 32k;
> proxy_busy_buffers_size    64k;
> proxy_temp_file_write_size 64k;
> 
> 
> Thanks in advance for any pointers.


> 
> I'm having a little trouble to get Mediawiki working in my nginx setup.
> 
> The problem is very probably the configuration of Mediawiki, but the
> Help pages about Mediawiki don't mention nginx.
> So I thought I ask here.
> 
> 
> My Problem:
> - I setup nginx with https such, that it handles all files, except php
> files, which fill be proxied to apache/mod_php at port 8081
> 
> - I installed a new Mediawiki
> 
> - the installation via the web worked fine and was confirmed
>     with a success message
> 
> - then I moved config/LocalSedttings.php  to the wiki directory
> 
> Now I access https:/servername/wiki2/
> and get redirected to http://servername:8081/wiki2/index.php/Main_Page
> 
> 
> Below my nginx configuration:
> 
> 
> # ============== nginx configuration ========
> server {
>     listen       443 ssl;
>     ssl_session_timeout  10m;
>     ssl_session_cache    shared:SSL:10m;
> 
>     location ~ \.(php)$ {
>         include proxy.conf;
>         proxy_pass         http://127.0.0.1:8081;
>     }
> 
>     # nginx shall serve all files except the php ones
>     location / {
>         root   /my/doc/root;
>         index  index.html index.htm index.php;
>     }
> 
> # ==================== proxy.conf ==============
> proxy_redirect     off;
> 
> proxy_set_header   Host             $host;
> proxy_set_header   X-Real-IP        $remote_addr;
> proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
> 
> client_max_body_size       10m;
> client_body_buffer_size    128k;
> 
> proxy_connect_timeout      90;
> proxy_send_timeout         90;
> proxy_read_timeout         90;
> 
> proxy_buffer_size          4k;
> proxy_buffers              4 32k;
> proxy_busy_buffers_size    64k;
> proxy_temp_file_write_size 64k;
> 
> 
> Thanks in advance for any pointers.




More information about the nginx mailing list