ammnt / freenginx

Distroless FreeNGINX with HTTP/3 and QUIC support (BoringSSL)🚀
https://msftcnsi.com/
8 stars 0 forks source link

Default nginx.conf #38

Closed phaleth closed 1 month ago

phaleth commented 1 month ago

Any chance to provide the default nginx.conf such as the following one, but maybe without logs enabled by default?

Also while leaving out the current server section and including the include line at the bottom so that the user of the image can copy in their own config or maybe override the /etc/nginx/conf.d/default.conf if it's present, as shown bellow.

# configuration file /etc/nginx/nginx.conf:

user  nginx;
worker_processes  auto;

error_log  /var/log/nginx/error.log notice;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

    include /etc/nginx/conf.d/*.conf;
}

Very nice and compact image, btw.

Example usage would then be:

FROM ghcr.io/ammnt/freenginx:main
...
COPY ./nginx.conf /etc/nginx/conf.d/default.conf
ammnt commented 1 month ago

@phaleth, thank you for your feedback. Good idea actually! I need to think about this :)

ammnt commented 1 month ago

Okay. it will be added during next release. Please pay attention that configuration path has been changed too: --conf-path=/etc/freenginx/freenginx.conf \

phaleth commented 1 month ago

That was quick. Thank you, @ammnt

phaleth commented 1 month ago

We have deployed one of our sites using the freenginx image and it works quite well.

Here's a little bit of a feedback. If I try to use port 8080 in a server section of my own included nginx.conf It's not serving the site that I need, even tho I provide the config at the /etc/freenginx/conf.d/ dir. The reason is that this port is already taken by a server section in freenginx.conf.

Would you consider moving away the server section from the default freenginx.conf to /etc/freenginx/conf.d/default.conf?

ammnt commented 1 month ago

@phaleth, I think it doesn't make sense because you can just mount and use your own global conf file. But I want to change default internal port and use above 8080 next time. So it has been changed to 35400.

phaleth commented 1 month ago

I guess it does make sense cause now there is a server running on port 35400 for no reason and so the freenginx engine needs to make it's workers aware of that unused server.

Please, take a look into what the official nginx image does by running one of those containers and checking the defaults by executing nginx -T within the container.

phaleth commented 1 month ago

Also I'd rather keep the defaults from your global freenginx.conf and adjust only what's really necessary in custom nginx.conf.

ammnt commented 1 month ago

I understand what you want to do, but what if you have more than one sites? In cases like these better change listen port in /etc/freenginx/conf.d/ conf files and keep global conf file I think.

phaleth commented 1 month ago

Great. In cases you have more than one site you definitely might want to create a new file in the /etc/freenginx/conf.d/ dir for each of those sites, while always inheriting defaults from your freenginx.conf.

ammnt commented 1 month ago

@phaleth, okay. I need to think about this.

ammnt commented 1 month ago

It's done now.

phaleth commented 1 month ago

Again, that was super quick. Thank you. @ammnt