ยินดีต้อนรับคุณ, บุคคลทั่วไป กรุณา เข้าสู่ระบบ หรือ ลงทะเบียน

เข้าสู่ระบบด้วยชื่อผู้ใช้ รหัสผ่าน และระยะเวลาในเซสชั่น

ThaiSEOBoard.comพัฒนาเว็บไซต์Programming[NGINX] ช่วยรวมชุดคำสั่ง 2 ไฟล์ ให้เป็นไฟล์เดียวหน่อยครับ
หน้า: [1]   ลงล่าง
พิมพ์
ผู้เขียน หัวข้อ: [NGINX] ช่วยรวมชุดคำสั่ง 2 ไฟล์ ให้เป็นไฟล์เดียวหน่อยครับ  (อ่าน 824 ครั้ง)
0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้
xmen256k
หัวหน้าแก๊งเสียว
*

พลังน้ำใจ: 97
ออฟไลน์ ออฟไลน์

กระทู้: 1,980



ดูรายละเอียด
« เมื่อ: 28 สิงหาคม 2016, 02:48:40 »

ชุดคำสั่งแรก เป็นคำสั่งสำหรับการ caching ครับ
โค๊ด:
server {
    listen      %ip%:%proxy_port%;
    server_name %domain_idn% %alias_idn%;
    error_log  /var/log/%web_system%/domains/%domain%.error.log error;

    location / {
        proxy_pass      http://%ip%:%web_port%;

        proxy_cache %domain%;
        proxy_cache_valid 15m;
        proxy_cache_valid 404 1m;
        proxy_no_cache $no_cache;
        proxy_cache_bypass $no_cache;
        proxy_cache_bypass $cookie_session $http_x_update;

        location ~* ^.+\.(%proxy_extentions%)$ {
            proxy_cache    off;
            root           %docroot%;
            access_log     /var/log/%web_system%/domains/%domain%.log combined;
            access_log     /var/log/%web_system%/domains/%domain%.bytes bytes;
            expires        max;
            try_files      $uri @fallback;
        }
    }

    location /error/ {
        alias   %home%/%user%/web/%domain%/document_errors/;
    }

    location @fallback {
        proxy_pass      http://%ip%:%web_port%;
    }

    location ~ /\.ht    {return 404;}
    location ~ /\.svn/  {return 404;}
    location ~ /\.git/  {return 404;}
    location ~ /\.hg/   {return 404;}
    location ~ /\.bzr/  {return 404;}

    include %home%/%user%/conf/web/nginx.%domain%.conf*;
}

ชุดคำสั่งสอง เป็นชุดคำสั่งสำหรับ wordpress ที่เอาไว้แก้ไขตรงจุดที่ nginx ไม่สามารถใช้งาน .htaccess ได้ครับ โดยแปลงให้สามารถใช้งานได้
โค๊ด:
server {
    listen      %ip%:%web_port%;
    server_name %domain_idn% %alias_idn%;
    root        %docroot%;
    index       index.php index.html index.htm;
    access_log  /var/log/nginx/domains/%domain%.log combined;
    access_log  /var/log/nginx/domains/%domain%.bytes bytes;
    error_log   /var/log/nginx/domains/%domain%.error.log error;

    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    location / {
        try_files $uri $uri/ /index.php?$args;

        location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
            expires     max;
        }

        location ~ [^/]\.php(/|$) {
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            if (!-f $document_root$fastcgi_script_name) {
                return  404;
            }

            fastcgi_pass    %backend_lsnr%;
            fastcgi_index   index.php;
            include         /etc/nginx/fastcgi_params;
        }
    }

    error_page  403 /error/404.html;
    error_page  404 /error/404.html;
    error_page  500 502 503 504 /error/50x.html;

    location /error/ {
        alias   %home%/%user%/web/%domain%/document_errors/;
    }

    location ~* "/\.(htaccess|htpasswd)$" {
        deny    all;
        return  404;
    }

    include     /etc/nginx/conf.d/phpmyadmin.inc*;
    include     /etc/nginx/conf.d/phppgadmin.inc*;
    include     /etc/nginx/conf.d/webmail.inc*;

    include     %home%/%user%/conf/web/nginx.%domain%.conf*;
}


========================================


ผมก็เลยอยากจะรวบคำสั่งการ caching ไปใช้กับชุดคำสั่ง wordpress ด้วยครับ

ไม่ทราบว่าควรนำจุดไหน ไปใส่ไหนจุดไหนบ้าง

ขอบคุณครับ
บันทึกการเข้า
nuonly
หัวหน้าแก๊งเสียว
*

พลังน้ำใจ: 143
ออฟไลน์ ออฟไลน์

กระทู้: 2,694



ดูรายละเอียด
« ตอบ #1 เมื่อ: 28 สิงหาคม 2016, 16:01:24 »

 wanwan016
บันทึกการเข้า

xmen256k
หัวหน้าแก๊งเสียว
*

พลังน้ำใจ: 97
ออฟไลน์ ออฟไลน์

กระทู้: 1,980



ดูรายละเอียด
« ตอบ #2 เมื่อ: 29 สิงหาคม 2016, 23:21:28 »

 wanwan011
บันทึกการเข้า
หน้า: [1]   ขึ้นบน
พิมพ์