NGINX 환경설정 생성기
Ubuntu 18.04 구성하기, Ubuntu 16.04 구성하기 글에서 사용하는 도구입니다. (Nginx 를 사용하는 모든 리눅스에서 사용 가능.)
 리눅스 사용자 아이디(*)
 
 웹 루트 디렉토리

웹사이트 구성 파일을 작성합니다.
/etc/nginx/conf.d/samplesite.com.conf 위치에 아래의 내용을 작성합니다.

일반 PHP 사이트

일반적인 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;
    }
}

+ 공지글


+ 최근글


  • 글이 없습니다.

+ 새댓글


  • 댓글이 없습니다.

통계


  • 현재 접속자 44 명
  • 오늘 방문자 195 명
  • 어제 방문자 215 명
  • 최대 방문자 1,150 명
  • 전체 방문자 434,147 명
  • 오늘 가입자 0 명
  • 어제 가입자 0 명
  • 전체 회원수 19 명
  • 전체 게시물 46 개
  • 전체 댓글수 31 개