Skip to content

Instantly share code, notes, and snippets.

@ninosimeon
Last active April 3, 2023 05:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ninosimeon/079f308e747b3ecb09875dde338198ab to your computer and use it in GitHub Desktop.
Save ninosimeon/079f308e747b3ecb09875dde338198ab to your computer and use it in GitHub Desktop.
PHP 7.1 Tweaks
// PATH : /etc/php/7.1/fpm/conf.d
expose_php = Off
serialize_precision = 17
max_execution_time = 180
max_input_time = 180
max_input_vars = 99999
memory_limit = 2G
date.timezone = America/Lima
session.gc_maxlifetime = 7200
post_max_size = 7M
upload_max_filesize = 5M
// PATH: /etc/php/7.1/fpm/pool.d
// mkdir -p /var/log/php-fpm/7.1
// touch /var/log/php-fpm/7.1/slowlog_php71_development.log
[php71_development]
listen = 127.0.0.1:9000
listen.allowed_clients = 127.0.0.1
listen.owner = www-data
listen.group = www-data
listen.backlog = -1
user = www-data
group = www-data
request_slowlog_timeout = 5s
slowlog = /var/log/php-fpm/7.1/slowlog_php71_development.log
pm = dynamic
pm.max_children = 4
pm.start_servers = 1
pm.min_spare_servers = 1
pm.max_spare_servers = 3
pm.max_requests = 20
request_terminate_timeout = 60s
rlimit_files = 50000
rlimit_core = unlimited
catch_workers_output = yes
server {
listen 80;
listen [::]:80;
server_name xyzxyz.pe www.xyzxyz.pe;
# Redirect all HTTP requests to HTTPS with a 301 Moved Permanently response.
return 301 https://xyzxyz.pe$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name www.xyzxyz.pe;
ssl_certificate /etc/letsencrypt/live/xyzxyz.pe/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/xyzxyz.pe/privkey.pem; # managed by Certbot
# Redirect all HTTP requests to HTTPS with a 301 Moved Permanently response.
return 301 https://xyzxyz.pe$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name xyzxyz.pe;
root /home/production/projects/xyzxyz.pe/fed-php-site/public;
access_log /home/production/projects/xyzxyz.pe/fed-php-site/logs/nginx-access.log;
error_log /home/production/projects/xyzxyz.pe/fed-php-site/logs/nginx-error.log;
error_page 404 /404.html;
index index.php;
server_tokens off;
ssl_certificate /etc/letsencrypt/live/xyzxyz.pe/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/xyzxyz.pe/privkey.pem; # managed by Certbot
ssl_session_timeout 1d;
ssl_session_cache shared:SSL:50m;
# Diffie-Hellman parameter for DHE ciphersuites, recommended 2048 bits
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
# intermediate configuration. tweak to your needs.
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS'; ssl_prefer_server_ciphers on;
# HSTS (ngx_http_headers_module is required) (15768000 seconds = 6 months)
add_header Strict-Transport-Security max-age=15768000;
# OCSP Stapling ---
# fetch OCSP records from URL in ssl_certificate and cache them
ssl_stapling on;
ssl_stapling_verify on;
add_header X-Frame-Options SAMEORIGIN;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header Referrer-Policy "origin";
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location = /robots.txt {access_log off;log_not_found off;}
location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
access_log off;
log_not_found off;
expires 360d;
}
location ~ /\. {
access_log off;
log_not_found off;
deny all;
}
location ~ \.php$ {
try_files $uri = 404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_read_timeout 300;
include /etc/nginx/fastcgi_params;
}
}
@ninosimeon
Copy link
Author

This snippet is only for development purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment