Last active
December 5, 2020 13:25
-
-
Save dausruddin/a4721ad02d29d33fa7a6fbbaa1f5e78a to your computer and use it in GitHub Desktop.
My configurations for openresty
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80 default_server; | |
listen [::]:80 default_server; | |
listen 443 default_server; | |
listen [::]:443 default_server; | |
server_name _; | |
# sudo openssl req -new -newkey rsa:4096 -x509 -sha256 -days 365 -nodes -out nginx.crt -keyout nginx.key | |
ssl_certificate /etc/openresty/nginx/conf/ssl/nginx.crt; | |
ssl_certificate_key /etc/openresty/nginx/conf/ssl/nginx.key; | |
return 403; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# regex to split $uri to $fastcgi_script_name and $fastcgi_path | |
fastcgi_split_path_info ^(.+?\.php)(/.*)$; | |
# Check that the PHP script exists before passing it | |
try_files $fastcgi_script_name =404; | |
# Bypass the fact that try_files resets $fastcgi_path_info | |
# see: http://trac.nginx.org/nginx/ticket/321 | |
set $path_info $fastcgi_path_info; | |
fastcgi_param PATH_INFO $path_info; | |
fastcgi_index index.php; | |
include fastcgi.conf; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user www-data; | |
worker_processes auto; | |
pid /etc/openresty/nginx/logs/nginx.pid; | |
events { | |
worker_connections 768; | |
# multi_accept on; | |
} | |
http { | |
## | |
# Basic Settings | |
## | |
sendfile on; | |
tcp_nopush on; | |
tcp_nodelay on; | |
keepalive_timeout 65; | |
types_hash_max_size 2048; | |
server_tokens off; | |
# server_names_hash_bucket_size 64; | |
# server_name_in_redirect off; | |
include /etc/openresty/nginx/conf/mime.types; | |
default_type application/octet-stream; | |
## | |
# Logging Settings | |
## | |
access_log /etc/openresty/nginx/logs/access.log; | |
error_log /etc/openresty/nginx/logs/error.log; | |
## | |
# Gzip Settings | |
## | |
gzip on; | |
# gzip_vary on; | |
# gzip_proxied any; | |
# gzip_comp_level 6; | |
# gzip_buffers 16 8k; | |
# gzip_http_version 1.1; | |
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; | |
## | |
# Virtual Host Configs | |
## | |
include /etc/openresty/nginx/conf/conf.d/*.conf; | |
include /etc/openresty/nginx/conf/sites-enabled/*; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Stop dance for OpenResty | |
# ========================= | |
# | |
# ExecStop sends SIGSTOP (graceful stop) to OpenResty's nginx process. | |
# If, after 5s (--retry QUIT/5) nginx is still running, systemd takes control | |
# and sends SIGTERM (fast shutdown) to the main process. | |
# After another 5s (TimeoutStopSec=5), and if nginx is alive, systemd sends | |
# SIGKILL to all the remaining processes in the process group (KillMode=mixed). | |
# | |
# nginx signals reference doc: | |
# http://nginx.org/en/docs/control.html | |
# | |
[Unit] | |
Description=full-fledged web platform | |
After=network.target | |
[Service] | |
Type=forking | |
PIDFile=/etc/openresty/nginx/logs/nginx.pid | |
ExecStartPre=/usr/local/bin/openresty -t -q -g 'daemon on; master_process on;' | |
ExecStart=/usr/local/bin/openresty -g 'daemon on; master_process on;' | |
ExecReload=/usr/local/bin/openresty -g 'daemon on; master_process on;' -s reload | |
ExecStop=-/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /etc/openresty/nginx/logs/nginx.pid | |
TimeoutStopSec=5 | |
KillMode=mixed | |
[Install] | |
WantedBy=multi-user.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment