Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chopped up nginx.conf, extracted the server block to /conf.d/default.conf #109

Merged
merged 1 commit into from
Jan 7, 2023

Conversation

doedje
Copy link
Contributor

@doedje doedje commented Nov 29, 2022

As requested in #98

If you just want to redefine a different server-block you can put .conf files in your conf.d directory like:

# conf.d/redirect.conf
server {
	listen 80 default_server;
	listen [::]:80 default_server;
	return 301 https://$host$request_uri;
}

and

# conf.d/my-https-site.conf
server {
	listen 443 default_server ssl;
	listen [::]:443 default_server ssl;
	...
}

You can now run the image as a new container with:

docker run -v "`pwd`/conf.d:/etc/nginx/conf.d" -p 80:80  -p 443:443 trafex/php-nginx

NOTE: don't forget to add a server-block for the healthcheck:

# conf.d/healthcheck.conf
server {
	listen 8080;
	listen [::]:8080;
	# Allow fpm ping and status from localhost
	location ~ ^/(fpm-status|fpm-ping)$ {
		access_log off;
		allow 127.0.0.1;
		deny all;
		fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
		include fastcgi_params;
		fastcgi_pass unix:/run/php-fpm.sock;
	}
}

EDIT: removed 'default_server' from the healthcheck server-block and fixed a typo

@TrafeX
Copy link
Owner

TrafeX commented Jan 7, 2023

Hi @doedje,

Thank you for your contribution! That's indeed exactly what's needed to split the http and server config.
I'll merge this in. Nice work!

@TrafeX TrafeX merged commit bf2732f into TrafeX:master Jan 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants