Sign inSign up

docphpro/nginx

By docphpro

•Updated 4 days ago

Image
0

10K+

docphpro/nginx repository overview

⁠Nginx

  • includes SSL -> /etc/ssl/phpro with wildcards as *.phpro.local

  • uses includes in /etc/nginx/includes

⁠example nginx 1

ssl-proxy.template

server {
    listen 443 ssl http2;
    server_name ${SERVER_NAME};
    ssl_certificate     /etc/ssl/phpro/star_phpro_local.pem;
    ssl_certificate_key /etc/ssl/phpro/star_phpro_local.key;

    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers AES256+EECDH:AES256+EDH:!aNULL;

    client_max_body_size 512M;

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

          location / {
              proxy_pass http://varnish:6081;
              proxy_set_header Host ${SERVER_NAME};
              #proxy_set_header X-Real-IP $remote_addr;
              #proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
              proxy_set_header X-Forwarded-Proto https;
              proxy_read_timeout    600;
              proxy_connect_timeout 600;
              proxy_redirect        off;
              proxy_set_header      X-VerifiedViaNginx yes;
              proxy_set_header      Proxy "";
              proxy_buffer_size	128k;
              proxy_buffers	4 256k;
              proxy_busy_buffers_size	256k;
          }
}

⁠Example nginx 2 with inclucdes

server {
    listen 443 ssl http2;
    server_name ${SERVER_NAME};
    ssl_certificate     /etc/ssl/phpro/star_phpro_local.pem;
    ssl_certificate_key /etc/ssl/phpro/star_phpro_local.key;

    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers AES256+EECDH:AES256+EDH:!aNULL;

    client_max_body_size 108M;

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

    include /etc/nginx/includes/${NGINX_FILE}.nginx.conf;
}

Includes

root /app/web;

location / {
    # try to serve file directly, fallback to index.php
    try_files $uri /app.php$is_args$args;
}

# optionally disable falling back to PHP script for the asset directories;
# nginx will return a 404 error when files are not found instead of passing the
# request to Symfony (improves performance but Symfony's 404 page is not displayed)
# location /bundles {
#     try_files $uri =404;
# }

location ~ ^/app\.php(/|$) {
    fastcgi_pass application:9000;
    fastcgi_split_path_info ^(.+\.php)(/.*)$;
    include fastcgi_params;

    # When you are using symlinks to link the document root to the
    # current version of your application, you should pass the real
    # application path instead of the path to the symlink to PHP
    # FPM.
    # Otherwise, PHP's OPcache may not properly detect changes to
    # your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126
    # for more information).
    fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
    fastcgi_param DOCUMENT_ROOT $realpath_root;
    # Prevents URIs that include the front controller. This will 404:
    # http://domain.tld/index.php/some-path
    # Remove the internal directive to allow URIs like this
    internal;
}

# return 404 for all other php files not matching the front controller
# this prevents access to other php files you don't want to be accessible.
location ~ \.php$ {
    return 404;
}

gzip on;
gzip_disable "msie6";

gzip_comp_level 6;
gzip_min_length 1100;
gzip_buffers 16 8k;
gzip_proxied any;
gzip_types
    text/plain
    text/css
    text/js
    text/xml
    text/javascript
    application/javascript
    application/x-javascript
    application/json
    application/xml
    application/xml+rss
    image/svg+xml;
gzip_vary on;

in docker compose you need to add the command to substitute the variables

⁠Example
  nginx:
    image: docphpro/nginx:1.18.0
    container_name: edmac-nginx-proxy
    volumes:
      - ./sysadmin/docker/nginx/ssl-proxy.template:/etc/nginx/conf.d/ssl-proxy.template:ro
    environment:
      - SERVER_NAME=edmac.phpro.local
    command: /bin/sh -c "envsubst < /etc/nginx/conf.d/ssl-proxy.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'" 
    links:
      - varnish
    ports:
      - "80:80"
      - "443:443"

Tag summary

Content type

Image

Digest

sha256:592cfec47…

Size

24.8 MB

Last updated

4 days ago

docker pull docphpro/nginx