Skip to content

Commit

Permalink
Test: docker
Browse files Browse the repository at this point in the history
  • Loading branch information
curious-mike-dvc committed Jul 20, 2024
1 parent 6746f5f commit f4ea3ad
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 189 deletions.
107 changes: 10 additions & 97 deletions config/nginx-default.conf
Original file line number Diff line number Diff line change
@@ -1,110 +1,23 @@
fastcgi_cache_path /dev/shm levels=1:2 keys_zone=laravel:100m;
fastcgi_cache_key "$scheme$request_method$host$request_uri$query_string";

map $http_x_forwarded_proto $fastcgi_param_https_variable {
default '';
https 'on';
}

error_log stderr;

server {
access_log /dev/stdout;

listen 8080 default_server;
server_name _;

index index.php index.html;
root /var/www/public;

#client_max_body_size 20M;
client_max_body_size 4G;

# Compression

# Enable Gzip compressed.
gzip on;

# Enable compression both for HTTP/1.0 and HTTP/1.1.
gzip_http_version 1.1;
listen 8080;
server_name localhost;

# Compression level (1-9).
# 5 is a perfect compromise between size and cpu usage, offering about
# 75% reduction for most ascii files (almost identical to level 9).
gzip_comp_level 5;

# Don't compress anything that's already small and unlikely to shrink much
# if at all (the default is 20 bytes, which is bad as that usually leads to
# larger files after gzipping).
gzip_min_length 256;

# Compress data even for clients that are connecting to us via proxies,
# identified by the "Via" header (required for CloudFront).
gzip_proxied any;

# Tell proxies to cache both the gzipped and regular version of a resource
# whenever the client's Accept-Encoding capabilities header varies;
# Avoids the issue where a non-gzip capable client (which is extremely rare
# today) would display gibberish if their proxy gave them the gzipped version.
gzip_vary on;

# Compress all output labeled with one of the following MIME-types.
gzip_types
application/atom+xml
application/javascript
application/json
application/rss+xml
application/vnd.ms-fontobject
application/x-font-ttf
application/x-web-app-manifest+json
application/xhtml+xml
application/xml
font/opentype
image/svg+xml
image/x-icon
image/jpeg
image/png
text/css
text/plain
text/x-component;
# text/html is always compressed by HttpGzipModule
root /var/www/html;
index index.php index.html index.htm;

location / {
try_files $uri $uri/ /index.php?$query_string;
try_files $uri $uri/ =404;
}

location ~ \.php$ {
root /var/www/public;
fastcgi_cache off;
fastcgi_cache_valid 200 204 1m;
fastcgi_ignore_headers Cache-Control;
fastcgi_no_cache $http_authorization $cookie_laravel_session;
fastcgi_cache_lock on;
fastcgi_cache_lock_timeout 10s;

# Bigger buffer size to handle cache invalidation headers expansion
fastcgi_buffer_size 32k;
fastcgi_buffers 8 16k;


add_header X-Proxy-Cache $upstream_cache_status;

fastcgi_pass localhost:9000;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS $fastcgi_param_https_variable;
fastcgi_read_timeout 900s;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

location ~* \.(jpg|jpeg|png|gif|ico|css|js|eot|ttf|woff|woff2)$ {
expires max;
add_header Cache-Control public;
add_header Access-Control-Allow-Origin *;
try_files $uri $uri/ /index.php?$query_string;
}

location ~ /\.ht {
deny all;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
23 changes: 23 additions & 0 deletions config/nginx-default.conf.working
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
server {
listen 8080;
server_name localhost;

root /var/www/html;
index index.php index.html index.htm;

location / {
try_files $uri $uri/ =404;
}

location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
107 changes: 15 additions & 92 deletions config/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,104 +1,27 @@
# Set number of worker processes automatically based on number of CPU cores.
worker_processes auto;

# Enables the use of JIT for regular expressions to speed-up their processing.
pcre_jit on;

# Configures default error logger.
error_log /dev/stderr warn;

# Includes files with directives to load dynamic modules.
include /etc/nginx/modules/*.conf;
user www-data;
worker_processes 1;

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

events {
# The maximum number of simultaneous connections that can be opened by
# a worker process.
worker_connections 1024;
worker_connections 1024;
}

http {
# Includes mapping of file name extensions to MIME types of responses
# and defines the default type.
include /etc/nginx/mime.types;
default_type application/octet-stream;

# Name servers used to resolve names of upstream servers into addresses.
# It's also needed when using tcpsocket and udpsocket in Lua modules.
#resolver 1.1.1.1 1.0.0.1 2606:4700:4700::1111 2606:4700:4700::1001;

# Don't tell nginx version to the clients. Default is 'on'.
server_tokens off;

# Specifies the maximum accepted body size of a client request, as
# indicated by the request header Content-Length. If the stated content
# length is greater than this size, then the client receives the HTTP
# error code 413. Set to 0 to disable. Default is '1m'.
client_max_body_size 4G;

# Sendfile copies data between one FD and other from within the kernel,
# which is more efficient than read() + write(). Default is off.
sendfile on;

# Causes nginx to attempt to send its HTTP response head in one packet,
# instead of using partial frames. Default is 'off'.
tcp_nopush on;


# Enables the specified protocols. Default is TLSv1 TLSv1.1 TLSv1.2.
# TIP: If you're not obligated to support ancient clients, remove TLSv1.1.
ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;

# Path of the file with Diffie-Hellman parameters for EDH ciphers.
# TIP: Generate with: `openssl dhparam -out /etc/ssl/nginx/dh2048.pem 2048`
#ssl_dhparam /etc/ssl/nginx/dh2048.pem;
include /etc/nginx/mime.types;
default_type application/octet-stream;

# Specifies that our cipher suits should be preferred over client ciphers.
# Default is 'off'.
ssl_prefer_server_ciphers on;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

# Enables a shared SSL cache with size that can hold around 8000 sessions.
# Default is 'none'.
ssl_session_cache shared:SSL:2m;
access_log /var/log/nginx/access.log main;

# Specifies a time during which a client may reuse the session parameters.
# Default is '5m'.
ssl_session_timeout 1h;
sendfile on;
#tcp_nopush on;

# Disable TLS session tickets (they are insecure). Default is 'on'.
ssl_session_tickets off;
keepalive_timeout 65;


# Enable gzipping of responses.
#gzip on;

# Set the Vary HTTP header as defined in the RFC 2616. Default is 'off'.
gzip_vary on;


# Helper variable for proxying websockets.
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}


# Specifies the main log format.
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

# Sets the path, format, and configuration for a buffered log write.
access_log /dev/stdout main;


# Includes virtual hosts configs.
include /etc/nginx/http.d/*.conf;

# WARNING: Don't use this directory for virtual hosts anymore.
# This include will be moved to the root context in Alpine 3.14.
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/conf.d/*.conf;
}

# TIP: Uncomment if you use stream module.
#include /etc/nginx/stream.conf;
27 changes: 27 additions & 0 deletions config/nginx.conf.working
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
user www-data;
worker_processes 1;

error_log /var/log/nginx/error.log warn;
pid /var/run/nginx/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;

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

0 comments on commit f4ea3ad

Please sign in to comment.