惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

爱范儿
爱范儿
博客园_首页
W
WeLiveSecurity
S
Secure Thoughts
S
Security @ Cisco Blogs
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Hugging Face - Blog
Hugging Face - Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
H
Hacker News: Front Page
Project Zero
Project Zero
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
U
Unit 42
N
News and Events Feed by Topic
N
News and Events Feed by Topic
Hacker News - Newest:
Hacker News - Newest: "LLM"
Forbes - Security
Forbes - Security
T
Tor Project blog
I
Intezer
B
Blog
F
Full Disclosure
Security Archives - TechRepublic
Security Archives - TechRepublic
F
Fortinet All Blogs
Schneier on Security
Schneier on Security
T
Threat Research - Cisco Blogs
AI
AI
Google DeepMind News
Google DeepMind News
L
LINUX DO - 最新话题
Cloudbric
Cloudbric
L
Lohrmann on Cybersecurity
WordPress大学
WordPress大学
博客园 - 聂微东
雷峰网
雷峰网
P
Privacy International News Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
PCI Perspectives
PCI Perspectives
Y
Y Combinator Blog
Spread Privacy
Spread Privacy
Simon Willison's Weblog
Simon Willison's Weblog
罗磊的独立博客
Vercel News
Vercel News
A
Arctic Wolf
The Register - Security
The Register - Security
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Microsoft Azure Blog
Microsoft Azure Blog
H
Heimdal Security Blog
Know Your Adversary
Know Your Adversary
P
Proofpoint News Feed
C
Cybersecurity and Infrastructure Security Agency CISA
P
Proofpoint News Feed

博客园 - 逝者如斯(乎)

Redis和Memcached的区别详解 分布式系统原理与范型 - 电子支付系统 CSS3 (1) - Beginner Shell Script (2) - global.sh Python (1) - 7 Steps to Mastering Machine Learning With Python Java面试题(1)- 高级特性 Master Nginx(8) - Troubleshooting Techniques Master Nginx(7) - Nginx for the Developer Master Nginx(6) - The Nginx HTTP Server Hadoop实战课程 Java EE (14) -- SSH配置 Self-Paced Training (3) - Docker Operations Self-Paced Training (2) - Docker Fundamentals Self-Paced Training (1) - Introduction to Docker Shell Script Tutorials (0 ~ 62) Master Nginx(5) - Reverse Proxy Advanced Topics Master Nginx(4) - Nginx as a Reverse Proxy Master Nginx(3) - Using the Mail Module Master Nginx(1) - Installing Nginx and Third-Party Modules
Mater Nginx(2) - A Configuration Guide
逝者如斯(乎) · 2016-02-01 · via 博客园 - 逝者如斯(乎)

由一个主配置文件和一些辅助配置文件构成,位于conf目录下

配置指令 指令参数(配置指令对应的值)

token串分为简单字符串或复合配置块({})

简单配置项 复杂配置项

error_page 500 502 /50x.html;

location / {
root /home/html;
index index.html index.htm
}

根据逻辑意义分成了多个作用域,即配置指令上下文

nginx支持的指令上下文,即作用域

main

http

server

location

mail

指令上下文,可能有包含的情况出现。例如,通常http上下文和mail上下文一定是出现在main上下文里。

user nobody;
worker_processes 1;
error_log logs/error.log info;

events {
worker_connections 1024;
}

http {
server {
listen 80;
server_name www.linuxdc.com;
}
}

The basic configuration format

Nginx global configuration parameters

Using include files

The HTTP server section

The virtual server section

Locations - where, when and how

The mail server section

Full sample configuration

Loadbalance

upstream web_backend {
    server 10.11.12.51
    server 10.11.12.52
}

server {
    listen 80;
    
    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://web_backend;
    }
}

///////////////////////////////////////////////////////////////////////////////////////////////////////

Starting, Stopping, and Reloading Configuration

nginx -s stop --fast shutdown
nginx -s quit --graceful shutdown
nginx -s reload --reloading the config file
nginx -s reopen --reopening the log files

kill -s QUIT 1628
ps -ax | grep nginx

Serving Static Content

/data/www --index.html
/data/images --some images

http {
    server {
        location / {
            root /data/www;
        }

        location /images/ {
            root /data;
        }
    }
}    

http://localhost/images/example.png -- /data/images/example.png
http://localhost/some/example.html -- /data/www/some/example.html

nginx -s reload

Find out reason in access.log or error.log, in the directory of /usr/local/nginx/logs or /var/log/nginx

Setting Up a Simple Proxy Server

http {
    server {
        location / {
            proxy_pass http://localhost:8080;
        }
        
        location ~ \.(gif|jpg|png)$ {
            root /data/images;
        }
    }
}

Setting Up FastCGI Proxying

http {
    server {
        location / {
            fastcgi_pass  localhost:9000;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param QUERY_STRING    $query_string;
        }

        location ~ \.(gif|jpg|png)$ {
            root /data/images;
        }
    }
}