Welcome! Log In Create A New Profile

Advanced

Re: Trouble adding /pma location to all virtual hosts

Francis Daly
June 26, 2013 05:34PM
On Wed, Jun 26, 2013 at 10:22:21AM -0400, Ben Johnson wrote:

Hi there,

> I was able to accomplish my objective with some help from the tutorial
> at:

It's good that you've got it working now.

There are a few things that you might like to consider when deploying
it across all vhosts.

First: for a request, nginx picks one server and then one location
to process things in. So for this configuration to be common across
multiple servers, you either must copy-paste it into each; or else put
it in an external file and "include" that file in each per-server config
that matters.

> location /pma {

Next, you probably want this to become "location ^~ /pma" -- or maybe
even "location ^~ /pma/", with a separate "location = /pma {return 301
/pma/;}" block.

http://nginx.org/r/location for the details of why that is.

(Hint: try to access /pmap, or /index.php, and you may see that things
go wrong.)

> root /var/www/;
> index index.php index.html index.htm;
> location ~ ^/pma/(.+\.php)$ {
> try_files $uri =404;
> root /var/www/;

That line, because it is identical to the enclosing one, probably does
nothing useful and can be removed.

> fastcgi_pass unix:/var/run/php5-fpm.sock;
> fastcgi_param HTTPS on;

You may be able to use the $https variable there, if you want to share
this config with both http and https servers *and* want to tell the
php server the truth about the original connection. But that's not
critical here.

> fastcgi_index index.php;
> fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
> include /etc/nginx/fastcgi_params;
> }
> location ~* ^/pma/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
> root /var/www/;
> }

That 3-line section, I don't think does anything useful as-is.

With it, requests that match are served from the filesystem below
/var/www/; while requests that don't match are served from the filesystem
below /var/www/.

Without it, requests won't match and so will be served from the filesystem
below /var/www/.

> }
> location /PMA {
> rewrite ^/* /pma last;
> }

That will match both /PMA and /PMA/, which are probably what you want.

It will also match /PMAP, which may be unrelated; and it will match
/PMA/file.png and rewrite it to just /pma, which may not be wanted.

The rewrite itself could omit the "/*" part and have the same effect.

I would suggest actively redirecting to the correct /pma/ url, rather
than trying an internal rewrite -- but again, if what you have works
for you, it's good enough.

> I don't know if the key is the nested location block, or something else.
> If anyone is able to point-out the fundamental differences between the
> configuration snippet that I posted previously and the snippet above,
> which actually works, I would be most appreciative.

You posted a few snippets previously. That last ones where you reported
404s, I failed to reproduce the 404s. They worked for me.

Possibly there was something else in the full configuration that meant
that the location{}s you showed were not the chosen ones for the requests
you made?

f
--
Francis Daly francis@daoine.org

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Trouble adding /pma location to all virtual hosts

Ben Johnson June 25, 2013 04:20PM

Re: Trouble adding /pma location to all virtual hosts

Ben Johnson June 26, 2013 10:24AM

Re: Trouble adding /pma location to all virtual hosts

Francis Daly June 26, 2013 05:34PM

Re: Trouble adding /pma location to all virtual hosts

Ben Johnson June 27, 2013 12:44PM

Re: Trouble adding /pma location to all virtual hosts

Ben Johnson June 27, 2013 12:56PM

Re: Trouble adding /pma location to all virtual hosts

Francis Daly June 27, 2013 07:10PM

Re: Trouble adding /pma location to all virtual hosts

Ben Johnson June 27, 2013 01:04PM

Re: Trouble adding /pma location to all virtual hosts

B.R. June 27, 2013 01:18PM

Re: Trouble adding /pma location to all virtual hosts

Ben Johnson June 27, 2013 02:10PM

Re: Trouble adding /pma location to all virtual hosts

B.R. June 27, 2013 03:10PM

Re: Trouble adding /pma location to all virtual hosts

Francis Daly June 27, 2013 07:14PM

Re: Trouble adding /pma location to all virtual hosts

Ben Johnson June 28, 2013 02:16PM

Re: Trouble adding /pma location to all virtual hosts

Francis Daly June 27, 2013 07:06PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 155
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready