nginx 1.10.1 설정

3735 단어
1.nginx.conf:
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
    worker_connections 768;
    # multi_accept on;
}

##### wss       1234  ,  2345  
stream {
    upstream stream_backend {
         server xxx.xxx.com:2345;
    }

    server {
        listen                1234 ssl;
        proxy_pass            stream_backend;

        ssl_certificate       /etc/nginx/ssl/xxx.crt;
        ssl_certificate_key   /etc/nginx/ssl/xxx.key;
        ssl_protocols         SSLv3 TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers           HIGH:!aNULL:!MD5;
        ssl_session_cache     shared:SSL:20m;
        ssl_session_timeout   4h;
        ssl_handshake_timeout 30s;
     }
}
####

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/nginx/mime.types;
    default_type application/octet-stream;

    ##
    # SSL Settings
    ##

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
    ssl_prefer_server_ciphers on;

    ##
    # Logging Settings
    ##

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    ##
    # Gzip Settings
    ##

    gzip on;
    gzip_disable "msie6";

    # 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/nginx/conf.d/*.conf;
        ###sites-enabled           
    include /etc/nginx/sites-enabled/*;
}


2. / etc / nginx / sites - available / xxx. xxx. com \ # 사이트 이름 을 프로필 로 만 든 후 / etc / nginx / sites - enabled / 아래 에 링크 를 만 듭 니 다. 예 를 들 어 ln -s /etc/nginx/sites-available/a /etc/nginx/sites-enable/axxx. xxx. com 8080 포트 와 443 설정:
server {
    listen 8080 default_server;
    listen [::]:8080 default_server;
    root /var/www/xxx.xxx.com;
    index index.php index.html index.htm index.nginx-debian.html;

    server_name xxx.xxx.com;

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

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
        # With php5-cgi alone:
        #fastcgi_pass 127.0.0.1:9000;
        # With php5-fpm:
        fastcgi_pass unix:/var/run/php5-fpm.sock; #         
        fastcgi_index index.php;
        include fastcgi_params;
    }
}

server {
    listen 443;
    ssl on;
    ssl_certificate /etc/nginx/ssl/xxx.crt;
    ssl_certificate_key /etc/nginx/ssl/xxx.key;
    server_name xxx.xxx.com;
    index index.html index.htm index.php;
    root /var/www/xxx.xxx.com;

    location / {
            index index.html index.php;
                ###    ,               thinkphp5.0.3  
            if (!-e $request_filename) {  
                rewrite ^(.*)$ /public/index.php?s=$1 last;  
                break;  
            }
        }
            
    location ~ \.php$ {
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
                # With php5-cgi alone:
                #fastcgi_pass 127.0.0.1:9000;
                # With php5-fpm:
                fastcgi_pass unix:/var/run/php5-fpm.sock; #         
                fastcgi_index index.php;
                include fastcgi_params;
        }
}

좋은 웹페이지 즐겨찾기