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

推荐订阅源

T
Tenable Blog
Last Week in AI
Last Week in AI
P
Proofpoint News Feed
Engineering at Meta
Engineering at Meta
H
Help Net Security
F
Fortinet All Blogs
MyScale Blog
MyScale Blog
宝玉的分享
宝玉的分享
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 司徒正美
量子位
N
Netflix TechBlog - Medium
Apple Machine Learning Research
Apple Machine Learning Research
小众软件
小众软件
Recorded Future
Recorded Future
博客园 - 三生石上(FineUI控件)
Vercel News
Vercel News
aimingoo的专栏
aimingoo的专栏
I
InfoQ
Microsoft Security Blog
Microsoft Security Blog
Scott Helme
Scott Helme
The Last Watchdog
The Last Watchdog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
IT之家
IT之家
AI
AI
WordPress大学
WordPress大学
Security Archives - TechRepublic
Security Archives - TechRepublic
Google Online Security Blog
Google Online Security Blog
U
Unit 42
V2EX - 技术
V2EX - 技术
MongoDB | Blog
MongoDB | Blog
Schneier on Security
Schneier on Security
博客园 - Franky
H
Heimdal Security Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Jina AI
Jina AI
W
WeLiveSecurity
P
Privacy & Cybersecurity Law Blog
Cloudbric
Cloudbric
B
Blog RSS Feed
N
News | PayPal Newsroom
S
Securelist
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
I
Intezer
Hacker News - Newest:
Hacker News - Newest: "LLM"
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
博客园_首页
罗磊的独立博客
H
Hackread – Cybersecurity News, Data Breaches, AI and More
雷峰网
雷峰网

博客园 - 白马黑衣

网络安全3 - Easy RSA重新签发客户端证书 RHEL - 笔记本合盖不休眠 RHEL - yum cache JFrog Artifactory 系列6 --- 其他配置 Node.js - 配置npm Rocky Linux 升级失败 Linux --- firewalld 2 - nfttables Linux - DNS Apache HTTP Server 关闭SELinux RHEL - 设置hostname和IP地址 Linux --- 查看PID 判断端口是否已经被占用 Maven 常用命令 Jenkins 系列3 --- pipeline Git自签名证书的验证 iptables Jenkins 系列2 --- Node/Agent Jenkins 系列1 --- 安装与配置
Nginx 系列2 --- 配置
白马黑衣 · 2023-12-16 · via 博客园 - 白马黑衣

一、概要

1. 承上启下

(1) Nginx 系列

二、配置

1. 测试配置

2. nginx配置文件

(1) 配置文件

sudo vi /etc/nginx/nginx.conf

(2) 关键配置

events {
  worker_connections  4096;  ## Default: 1024
}
http {
  server {
    listen 80;
    listen [::]:80;
    server_name localhost;
    location / {
      root /etc/nginx/html;
      index index.html index.htm;
    }
  }
}

a. listen: 是nginx需要监听的端口号;

b. server_name: 是nginx代理的域名,如果配置成.example.com,则example.com所有子域名都会被命中;

c. location: 存储路径信息,这里root指http网站的根目录:

请求http://www.example.com/,返回页面对应的目录是/etc/nginx/html/index.html。

3. 子配置文件

(1) 按需创建

sudo vi /etc/nginx/conf.d/http
sudo vi /etc/nginx/conf.d/stream
sudo vi /etc/nginx/conf.d/mail
sudo vi /etc/nginx/conf.d/exchange-enhanced

a. Events: 一般链接处理;

b. Http: Http模块;

c. Mail: 邮件模块;

d. Stream: TCP和UDP流量。

(2) 在/etc/nginx/nginx.conf中按需添加引用

include /etc/nginx/conf.d/http/*.conf;
include /etc/nginx/conf.d/stream/*.conf;
include /etc/nginx/conf.d/exchange-enhanced/*.conf;

4. 配置证书

(1) Letscrypt证书

参考Letscrypt

(2) SELinux

使用自签发证书时,如果服务器开启了SELinux可能会出现Nginx无法加载证书文件的问题,此时需要运行以下命令解决:

sudo restorecon -v -R /etc/nginx/ssl

注意,/etc/nginx/ssl是证书所在的目录。

三、参考

1. 官方

http://nginx.org/en/docs/

http://nginx.org/en/docs/ngx_core_module.html

http://nginx.org/en/docs/http/ngx_http_core_module.html

http://nginx.org/en/docs/http/ngx_http_charset_module.html

http://nginx.org/en/docs/http/ngx_http_log_module.html

http://nginx.org/en/docs/mail/ngx_mail_ssl_module.html

http://nginx.org/en/docs/http/ngx_http_index_module.html

2. 其他

https://www.digitalocean.com/community/tools/nginx