[kwlug-disc] nginx config question

Ronald Barnes ron at ronaldbarnes.ca
Thu Sep 28 02:25:52 EDT 2023


I've switched everything over to nginx and have a question.


I include a lot of config snippets, including one that checks for /ping, 
/status, etc.

Those have stanzas like this:

location /ping {
   include fastcgi.conf;

   ## This MUST run on the NORMAL listening socket, NOT the special
   ## pm.status_listen defined in /etc/php/$version/fpm/pool.d/www.conf:
   fastcgi_pass unix:/run/php/php-fpm.sock;
   }


The server block that includes it might look like this:

server {
   listen 80 ;

   server_name nextcloud.bclug.ca;

   ## Enable responses to /ping ... "pong", etc:
   include ./sites-available/shared/ping.conf;

   return 301 https://$host$request_uri;
   }


So... if I `curl nextcloud.bclug.ca/ping` I want "pong", not a 301 
redirect to https://nextcloud.bclug.ca/ping (which works).


Is there a way to do this?  I might be missing some critical 
understanding of nginx.

I'm trying to avoid repeating the location blocks that are being included...


The include statement is repeated in the https section, and it works.

If I use `curl -L nextcloud.bclug.ca/ping` then I do get "pong" after 
the redirect.


Can the redirect be avoided for /ping ?


Thanks!

rb



More information about the kwlug-disc mailing list