- NGINX Cookbook
- Tim Butler
- 226字
- 2021-07-03 00:04:21
How it works...
Let's go through this setup file to understand each directive:
- listen 80;: This defines the port which NGINX will listen to. Port 80 is the default standard for HTTP, which is why it doesn't need to be specified in the browser URL.
- server_name server.yourname.com;: This directive tells the server what hostname to match from the request. This allows you to run name-based virtual servers from one IP address, but with different domain names. You can also use different aliases here; for example, you can have both www.yourname.com and yourname.com.
- access_log /var/log/nginx/log/host.access.log combined;: The access log records all client access to the site, stores it in the specified file (the second parameter), and uses the third parameter to define the format of the log (combined is the default).
- location: Lastly, we have a location block directive. This one is for a root directive (represented by /), meaning everything in the URL path. There are then two directives contained within this block—the first is the root directive. This defines where NGINX should look for the files.
- index: The second is the index directive. This lets NGINX know what name of a file to try if it hasn't been specified in the path. For example, if you put http://server.yourname.com/ into your browser, NGINX will try to load http://server.yourname.com/index.html instead of displaying a 404 error.
推薦閱讀
- Microsoft Exchange Server PowerShell Cookbook(Third Edition)
- 軟件架構設計:大型網站技術架構與業務架構融合之道
- Java Web基礎與實例教程(第2版·微課版)
- 控糖控脂健康餐
- 深入實踐Spring Boot
- STM32F0實戰:基于HAL庫開發
- Python:Master the Art of Design Patterns
- R大數據分析實用指南
- Spring+Spring MVC+MyBatis整合開發實戰
- 青少年學Python(第1冊)
- Spring+Spring MVC+MyBatis從零開始學
- 深入理解C指針
- Raspberry Pi Robotic Blueprints
- Illustrator CC平面設計實戰從入門到精通(視頻自學全彩版)
- Instant Zurb Foundation 4