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

相关文章
相关标签/搜索