https://unit.nginx.org/integration/
與NGINX集成
在NGINX后面安裝單元
將NGINX配置為靜態Web服務器,並在Unit前面配置反向代理。
NGINX直接從文件系統提供靜態文件,對應用程序的請求被轉發到Unit。
在httpNGINX配置的上下文中創建上游塊,並將Unit服務器IP和端口添加到上游塊,例如:
upstream unit_backend { server 127.0.0.1:8300; }
在NGINX配置的上下文中創建或修改server和location阻止http。指定靜態文件目錄和上游單元的名稱。
例1
對於PHP應用程序,所有以URL結尾的請求.php都將代理到Unit。所有其他文件將由NGINX直接提供:
server { location / { root /var/www/static-data; } location ~ \.php$ { proxy_pass http://unit_backend; proxy_set_header Host $host; } }
例2
對於以下應用程序,所有靜態文件都需要放在 /var/www/files目錄中,並以URL開頭引用/static。所有其他請求將代理到單位:
server { location /static { root /var/www/files; } location / { proxy_pass http://unit_backend; proxy_set_header Host $host; } }
有關更多信息,請參閱https://nginx.org上的NGINX文檔。https://www.nginx.com上提供了商業支持和高級功能。
