phpmyadmin on apache behind https nginx

Jim Ohlstein jim at ohlste.in
Wed Jul 13 22:27:06 MSD 2011


On 7/13/11 1:19 PM, Gelonida wrote:
> Hi,
> 
> I'm just starting to use nginx.
> I'm not sure, whether my nginx configuration is wrong or
> whether there are some parameters do be changed in phpmyadmin, such,
> that it works well behind a reverse proxy.
> 
> Currently phpmyadmin is running on apache.
> 
> What I wanted to do is use nginx (https) as front end
> and use it to serve all the static contents
> 
> and keep apache (for the time being) for the php contents
> 
> 
> The nginx config  I use is:
> 
>     location /phpmyadmin {
>         alias /usr/share/phpmyadmin/;
>         index index.php;
>     }
>     location ~ .php$ {
>         # Use apache for the time being
>         proxy_pass http://127.0.0.1:8080;
>         include proxy.conf;
>     }
> 
>     location / {
>         root   /var/www;
>         index  index.html index.htm;
>     }
> 
> 
> my apache configuration is
> Alias /phpmyadmin /usr/share/phpmyadmin
> 
> 
> I tested phpmyadmin after reconfigring apache
> http://hostname:8080/phpmyadmin
> 
> 
> When running behind nginx following happens:
> - I get the login screen
> - I enter user name and password
> - I am redirected to
> http://hostname:8080/index.php?...
> instead of http://hostname/index.php?... thus
> the browser tries connect directly to the ptoxied server.
> 
> This will stop working as soon as I let listen apache only on the
> localhost.
> 
> forther I'd like to give access to phpmyadmin only via https:

Try something like this:

server {
    ...
    listen 80;
    ...
    location /phpmyadmin {
	rewrite ^ https://yourhost$request_uri? permanent;
        ...
    }
    ...
}

server {
    ...
    listen 443;
     ssl on;
    ... # ssl configs
    location /phpmyadmin {
	root /usr/share;
	auth_basic "Enter password"; #optional
	auth_basic_user_file /path/to/htpasswd;

	#required here if using auth_basic
	location ~ \.php {
	    proxy_pass ...
	}
}

I use a similar setup in FreeBSD though the path to phpMyAdmin is
different and I use fastcgi. YMMV.

> 
> 
> What are the parameters, that I have to modify
> in nginx (or phpmyadmin) to make my setup work.
> 
> Thanks in advance for your help.
> 
> 
> 
> 
> 
> 
> 
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://nginx.org/mailman/listinfo/nginx


-- 
Jim Ohlstein



More information about the nginx mailing list