nginx---Beginner's Guide

一 启动

nginx -s signal

Where signal may be one of the following:

  • stop — fast shutdown
  • quit — graceful shutdown
  • reload — reloading the configuration file
  • reopen — reopening the log files

nginx -c nginx.conf  指定配置文件

二 配置文件

块关系

  main    *events

         *http       **server    ***location     

      

三 目录设置

设置文件根目录

location / {
    root /data/www;
}

四 简单代理设置

设置1


server {
  代理服务器IP+PORT设置 location / { proxy_pass http://localhost:8080/; }
所有 .(gif|jpg|png) 文件均访问本服务器,其他文件访问代理服务器
~ 表示后面为正则表达式 location ~ .(gif|jpg|png)$ { root /data/images; }
}

设置2

server {
  所有.html文件都访问代理服务器 location ~ *.html$ { proxy_pass http://localhost:8080/; } }

五 FastCGI代理设置

所有.cgi请求都访问FastCGI代理
location ~ *.cgi$ {
  设置FastCGI代理IP+PORT fastcgi_pass localhost:9000;
  设置默认.cgi fastcgi_index index.cgi;
  包含fastcgi.conf中的所有fastcgi_param include fastcgi.conf }
原文地址:https://www.cnblogs.com/jokoz/p/5387859.html