/etc/nginx/conf.d/samplesite.com.conf
위치에 아래의 내용을 작성합니다.
일반적인 PHP 사이트 (그누보드 등)
server { listen 80; server_name samplesite.com www.samplesite.com anothersite.net; root /home/myuser1/www; server_tokens off; add_header X-Frame-Options SAMEORIGIN; add_header X-Content-Type-Options nosniff; add_header X-XSS-Protection "1; mode=block"; charset utf-8; #set same size as post_max_size(php.ini or php_admin_value). client_max_body_size 10M; access_log /var/log/nginx/samplesite.com.access.log main; error_log /var/log/nginx/samplesite.com.error.log error; location / { index index.php index.html; } # Allow Lets Encrypt Domain Validation Program location ^~ /.well-known/acme-challenge/ { allow all; } # Block dot file (.htaccess .htpasswd .svn .git .env and so on.) location ~ /\. { deny all; } # Block (log file, binary, certificate, shell script, sql dump file) access. location ~* \.(log|binary|pem|enc|crt|conf|cnf|sql|sh|key|yml|lock)$ { deny all; } # Block access location ~* (composer\.json|composer\.lock|composer\.phar|contributing\.md|license\.txt|readme\.rst|readme\.md|readme\.txt|copyright|artisan|gulpfile\.js|package\.json|phpunit\.xml|access_log|error_log|gruntfile\.js)$ { deny all; } location = /favicon.ico { log_not_found off; access_log off; } location = /robots.txt { log_not_found off; access_log off; } # Block .php file inside upload folder. uploads(wp), files(drupal), data(gnuboard). location ~* /(?:uploads|default/files|data)/.*\.php$ { deny all; } location ~* /(?:uploads/session)/.* { deny all; } # Add PHP handler location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; if (!-f $document_root$fastcgi_script_name) { return 404; } fastcgi_read_timeout 300; fastcgi_pass unix:/run/php/myuser1.sock; fastcgi_index index.php; fastcgi_buffers 64 16k; # default 8 4k include fastcgi_params; } }