nginx筆記

31 March 2020
cs cs nginx reverse_proxy

此文章僅用來紀錄學習nginx的過程

nginx發送信號


nginx -s signal
關閉nginx
# fast stop
nginx -s stop

# gracefully shotdown
nginx -s quit
重啟nginx
# changed configuration file will note be loaded until this command is evoked
nginx -s reload

systemctl


使用systemctl來啟動nginx

retart nginx
sudo systemctl restart nginx

Configuration File Structure


simple directive
# simple directive example
# <name> <value>;
listen 8080;
block directive
# block directive example
# <name> {
#  ...
# }
http {
	server {

	}
}

nginx.conf / site-enabled


nginx.conf最後可以看到會引入/site-enabled/*所有檔案,在啟動nginx時會先讀取nginx.conf這個設定檔,而後會引入其他自訂的設定檔

# /etc/nginx/nginx.conf

...

http {
...

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*; 

}

Reference


  1. 基本範例教學
  2. 英文官方教學
  3. node.js + nginx 新手簡單配置
  4. nginx基礎設定教學