Nginx如何反向代理網站和設置虛擬主機

# 反向代理其餘網站服務器 
# proxy reverse setting. 
server {     
       listen       port ;     
       server_name   domainname(FQDN) ;     
       location / {     
           proxy_pass http://{ipaddress | domainname(FQDN)} ;     
           proxy_set_header Host $host;     
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;     
       }     
}     
# 虛擬主機設置 
# vhost setting 
server     
       {     
               listen       port ;     
               server_name {ipaddress | domainname(FQDN)} ;     
               index index.html index.htm index.php default.html default.htm default.php; # 根據須要選擇順序     
               root   /web contents path ;     
               include none.conf;     
               location ~ .*\.(php|php5)?$     
                       {     
                               try_files $uri =404;     
                               fastcgi_pass  unix:/tmp/php-cgi.sock;     
                               fastcgi_index index.php;     
                               include fcgi.conf;     
                       }     
               location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$     
                       {     
                               expires      30d;     
                       }     
               location ~ .*\.(js|css)?$     
                       {     
                               expires      12h;     
                       }     
               access_log off;     
       }     php

相關文章
相關標籤/搜索