Nginx

NGINX 無法啟動:不允許使用 localtion 指令

  • January 21, 2016

Nginx 沒有啟動或重新啟動,並給出錯誤:“nginx:

$$ emerg $$/home/admin/conf/web/nginx.conf:100 中不允許使用“位置”指令。 我知道這是因為位置部分不在 {} 標記內,但是這個帳戶的配置文件非常大,我不知道如何解決這個問題。

舊程式碼佔用了太多空間來發布。

謝謝你的幫助!

更新配置:

server {
listen      192.168.0.39:80;
server_name test-page.ga www.test-page.ga;
error_log  /var/log/apache2/domains/test-page.ga.error.log error;

location / {
   proxy_pass      http://192.168.0.39:8080;
   location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|tif|tiff|css|js|htm|html|ttf|otf|webp|woff|txt|csv|rtf|doc|docx|xls|xlsx|ppt|pptx|odf|odp|ods|odt|pdf|psd|ai|eot|eps|ps|zip|tar|tgz|gz|rar|bz2|7z|aac|m4a|mp3|mp4|ogg|wav|wma|3gp|avi|flv|m4v|mkv|mov|mp4|mpeg|mpg|wmv|exe|iso|dmg|swf)$ {
       root           /home/admin/web/test-page.ga/public_html;
       access_log     /var/log/apache2/domains/test-page.ga.log combined;
       access_log     /var/log/apache2/domains/test-page.ga.bytes bytes;
       expires        max;
       try_files      $uri @fallback;
   }
}

location /error/ {
   alias   /home/admin/web/test-page.ga/document_errors/;
}

location @fallback {
   proxy_pass      http://192.168.0.39:8080;
}

location ~ /\.ht    {return 404;}
location ~ /\.svn/  {return 404;}
location ~ /\.git/  {return 404;}
location ~ /\.hg/   {return 404;}
location ~ /\.bzr/  {return 404;}

include /home/admin/conf/web/nginx.test-page.ga.conf*;
}

server {
listen      192.168.0.39:80;
server_name mailmyserver.ga www.mailmyserver.ga;
error_log  /var/log/apache2/domains/mailmyserver.ga.error.log error;

location / {
   proxy_pass      http://192.168.0.39:8080;
   location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|tif|tiff|css|js|htm|html|ttf|otf|webp|woff|txt|csv|rtf|doc|docx|xls|xlsx|ppt|pptx|odf|odp|ods|odt|pdf|psd|ai|eot|eps|ps|zip|tar|tgz|gz|rar|bz2|7z|aac|m4a|mp3|mp4|ogg|wav|wma|3gp|avi|flv|m4v|mkv|mov|mp4|mpeg|mpg|wmv|exe|iso|dmg|swf)$ {
       root           /home/admin/web/mailmyserver.ga/public_html;
       access_log     /var/log/apache2/domains/mailmyserver.ga.log combined;
       access_log     /var/log/apache2/domains/mailmyserver.ga.bytes bytes;
       expires        max;
       try_files      $uri @fallback;
   }
}

location /error/ {
   alias   /home/admin/web/mailmyserver.ga/document_errors/;
}

location @fallback {
   proxy_pass      http://192.168.0.39:8080;
}

location ~ /\.ht    {return 404;}
location ~ /\.svn/  {return 404;}
location ~ /\.git/  {return 404;}
location ~ /\.hg/   {return 404;}
location ~ /\.bzr/  {return 404;}

include /home/admin/conf/web/nginx.mailmyserver.ga.conf*;
}

server {
listen      192.168.0.39:80;
server_name globalcdg.ga www.globalcdg.ga;
error_log  /var/log/apache2/domains/globalcdg.ga.error.log error;

location / {
   proxy_pass      http://192.168.0.39:8080;
   location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|tif|tiff|css|js|htm|html|ttf|otf|webp|woff|txt|csv|rtf|doc|docx|xls|xlsx|ppt|pptx|odf|odp|ods|odt|pdf|psd|ai|eot|eps|ps|zip|tar|tgz|gz|rar|bz2|7z|aac|m4a|mp3|mp4|ogg|wav|wma|3gp|avi|flv|m4v|mkv|mov|mp4|mpeg|mpg|wmv|exe|iso|dmg|swf)$ {
       root           /home/admin/web/globalcdg.ga/public_html;
       access_log     /var/log/apache2/domains/globalcdg.ga.log combined;
       access_log     /var/log/apache2/domains/globalcdg.ga.bytes bytes;
       expires        max;
       try_files      $uri @fallback;
   }
}

location /error/ {
   alias   /home/admin/web/globalcdg.ga/document_errors/;
}

location @fallback {
   proxy_pass      http://192.168.0.39:8080;
}

location ~ /\.ht    {return 404;}
location ~ /\.svn/  {return 404;}
location ~ /\.git/  {return 404;}
location ~ /\.hg/   {return 404;}
location ~ /\.bzr/  {return 404;}

include /home/admin/conf/web/nginx.globalcdg.ga.conf*;
}

server {
listen      192.168.0.39:80;
server_name lifepost.site www.lifepost.site;
error_log  /var/log/apache2/domains/lifepost.site.error.log error;

location / {
   proxy_pass      http://192.168.0.39:8080;
   location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|tif|tiff|css|js|htm|html|ttf|otf|webp|woff|txt|csv|rtf|doc|docx|xls|xlsx|ppt|pptx|odf|odp|ods|odt|pdf|psd|ai|eot|eps|ps|zip|tar|tgz|gz|rar|bz2|7z|aac|m4a|mp3|mp4|ogg|wav|wma|3gp|avi|flv|m4v|mkv|mov|mp4|mpeg|mpg|wmv|exe|iso|dmg|swf)$ {
       root           /home/admin/web/lifepost.site/public_html;
       access_log     /var/log/apache2/domains/lifepost.site.log combined;
       access_log     /var/log/apache2/domains/lifepost.site.bytes bytes;
       expires        max;
       try_files      $uri @fallback;
   }
}

location /error/ {
   alias   /home/admin/web/lifepost.site/document_errors/;
}

location @fallback {
   proxy_pass      http://192.168.0.39:8080;
}

location ~ /\.ht    {return 404;}
location ~ /\.svn/  {return 404;}
location ~ /\.git/  {return 404;}
location ~ /\.hg/   {return 404;}
location ~ /\.bzr/  {return 404;}

include /home/admin/conf/web/nginx.lifepost.site.conf*;
}

server {
listen      192.168.0.39:80;
server_name cdgmediagroup.com www1.cdgmediagroup.com www.cdgmediagroup.com;
error_log  /var/log/apache2/domains/cdgmediagroup.com.error.log error;

location / {
   proxy_pass      http://192.168.0.39:8080;
   location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|tif|tiff|css|js|htm|html|ttf|otf|webp|woff|txt|csv|rtf|doc|docx|xls|xlsx|ppt|pptx|odf|odp|ods|odt|pdf|psd|ai|eot|eps|ps|zip|tar|tgz|gz|rar|bz2|7z|aac|m4a|mp3|mp4|ogg|wav|wma|3gp|avi|flv|m4v|mkv|mov|mp4|mpeg|mpg|wmv|exe|iso|dmg|swf)$ {
       root           /home/admin/web/cdgmediagroup.com/public_html;
       access_log     /var/log/apache2/domains/cdgmediagroup.com.log combined;
       access_log     /var/log/apache2/domains/cdgmediagroup.com.bytes bytes;
       expires        max;
       try_files      $uri @fallback;
   }
}

location /error/ {
   alias   /home/admin/web/cdgmediagroup.com/document_errors/;
}

location @fallback {
   proxy_pass      http://192.168.0.39:8080;
}

location ~ /\.ht    {return 404;}
location ~ /\.svn/  {return 404;}
location ~ /\.git/  {return 404;}
location ~ /\.hg/   {return 404;}
location ~ /\.bzr/  {return 404;}

include /home/admin/conf/web/nginx.cdgmediagroup.com.conf*;
}

server {
listen      192.168.0.39:80;
server_name cartergames.ga www.cartergames.ga;
error_log  /var/log/apache2/domains/cartergames.ga.error.log error;

location / {
   proxy_pass      http://192.168.0.39:8080;
   location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|tif|tiff|css|js|htm|html|ttf|otf|webp|woff|txt|csv|rtf|doc|docx|xls|xlsx|ppt|pptx|odf|odp|ods|odt|pdf|psd|ai|eot|eps|ps|zip|tar|tgz|gz|rar|bz2|7z|aac|m4a|mp3|mp4|ogg|wav|wma|3gp|avi|flv|m4v|mkv|mov|mp4|mpeg|mpg|wmv|exe|iso|dmg|swf)$ {
       root           /home/admin/web/cartergames.ga/public_html;
       access_log     /var/log/apache2/domains/cartergames.ga.log combined;
       access_log     /var/log/apache2/domains/cartergames.ga.bytes bytes;
       expires        max;
       try_files      $uri @fallback;
   }
}

location /error/ {
   alias   /home/admin/web/cartergames.ga/document_errors/;
}

location @fallback {
   proxy_pass      http://192.168.0.39:8080;
}

location ~ /\.ht    {return 404;}
location ~ /\.svn/  {return 404;}
location ~ /\.git/  {return 404;}
location ~ /\.hg/   {return 404;}
location ~ /\.bzr/  {return 404;}

include /home/admin/conf/web/nginx.cartergames.ga.conf*;
}

server {
listen      192.168.0.39:80;
server_name oregondate.space www.oregondate.space;
error_log  /var/log/apache2/domains/oregondate.space.error.log error;

location / {
   proxy_pass      http://192.168.0.39:8080;
   location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|tif|tiff|css|js|htm|html|ttf|otf|webp|woff|txt|csv|rtf|doc|docx|xls|xlsx|ppt|pptx|odf|odp|ods|odt|pdf|psd|ai|eot|eps|ps|zip|tar|tgz|gz|rar|bz2|7z|aac|m4a|mp3|mp4|ogg|wav|wma|3gp|avi|flv|m4v|mkv|mov|mp4|mpeg|mpg|wmv|exe|iso|dmg|swf)$ {
       root           /home/admin/web/oregondate.space/public_html;
       access_log     /var/log/apache2/domains/oregondate.space.log combined;
       access_log     /var/log/apache2/domains/oregondate.space.bytes bytes;
       expires        max;
       try_files      $uri @fallback;
   }
}

location /error/ {
   alias   /home/admin/web/oregondate.space/document_errors/;
}

location @fallback {
   proxy_pass      http://192.168.0.39:8080;
}

location ~ /\.ht    {return 404;}
location ~ /\.svn/  {return 404;}
location ~ /\.git/  {return 404;}
location ~ /\.hg/   {return 404;}
location ~ /\.bzr/  {return 404;}

include /home/admin/conf/web/nginx.oregondate.space.conf*;
}

server {
listen      192.168.0.39:80;
server_name testdummies.cf www.testdummies.cf;
error_log  /var/log/apache2/domains/testdummies.cf.error.log error;

location / {
   proxy_pass      http://192.168.0.39:8080;
   location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|tif|tiff|css|js|htm|html|ttf|otf|webp|woff|txt|csv|rtf|doc|docx|xls|xlsx|ppt|pptx|odf|odp|ods|odt|pdf|psd|ai|eot|eps|ps|zip|tar|tgz|gz|rar|bz2|7z|aac|m4a|mp3|mp4|ogg|wav|wma|3gp|avi|flv|m4v|mkv|mov|mp4|mpeg|mpg|wmv|exe|iso|dmg|swf)$ {
       root           /home/admin/web/testdummies.cf/public_html;
       access_log     /var/log/apache2/domains/testdummies.cf.log combined;
       access_log     /var/log/apache2/domains/testdummies.cf.bytes bytes;
       expires        max;
       try_files      $uri @fallback;
   }
}

location /error/ {
   alias   /home/admin/web/testdummies.cf/document_errors/;
}

location @fallback {
   proxy_pass      http://192.168.0.39:8080;
}

location ~ /\.ht    {return 404;}
location ~ /\.svn/  {return 404;}
location ~ /\.git/  {return 404;}
location ~ /\.hg/   {return 404;}
location ~ /\.bzr/  {return 404;}

include /home/admin/conf/web/nginx.testdummies.cf.conf*;
}

server {
listen      192.168.0.39:80;
server_name cdg.tech www.cdg.tech;
error_log  /var/log/apache2/domains/cdg.tech.error.log error;

location / {
   proxy_pass      http://192.168.0.39:8080;
   location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|tif|tiff|css|js|htm|html|ttf|otf|webp|woff|txt|csv|rtf|doc|docx|xls|xlsx|ppt|pptx|odf|odp|ods|odt|pdf|psd|ai|eot|eps|ps|zip|tar|tgz|gz|rar|bz2|7z|aac|m4a|mp3|mp4|ogg|wav|wma|3gp|avi|flv|m4v|mkv|mov|mp4|mpeg|mpg|wmv|exe|iso|dmg|swf)$ {
       root           /home/admin/web/cdg.tech/public_html;
       access_log     /var/log/apache2/domains/cdg.tech.log combined;
       access_log     /var/log/apache2/domains/cdg.tech.bytes bytes;
       expires        max;
       try_files      $uri @fallback;
   }
}

location /error/ {
   alias   /home/admin/web/cdg.tech/document_errors/;
}

location @fallback {
   proxy_pass      http://192.168.0.39:8080;
}

location ~ /\.ht    {return 404;}
location ~ /\.svn/  {return 404;}
location ~ /\.git/  {return 404;}
location ~ /\.hg/   {return 404;}
location ~ /\.bzr/  {return 404;}

include /home/admin/conf/web/nginx.cdg.tech.conf*;
}

server {
listen      192.168.0.39:80;
server_name complexwebs.com www1.complexwebs.com www.complexwebs.com;
error_log  /var/log/apache2/domains/complexwebs.com.error.log error;

location / {
   proxy_pass      http://192.168.0.39:8080;
   location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|tif|tiff|css|js|htm|html|ttf|otf|webp|woff|txt|csv|rtf|doc|docx|xls|xlsx|ppt|pptx|odf|odp|ods|odt|pdf|psd|ai|eot|eps|ps|zip|tar|tgz|gz|rar|bz2|7z|aac|m4a|mp3|mp4|ogg|wav|wma|3gp|avi|flv|m4v|mkv|mov|mp4|mpeg|mpg|wmv|exe|iso|dmg|swf)$ {
       root           /home/admin/web/complexwebs.com/public_html;
       access_log     /var/log/apache2/domains/complexwebs.com.log combined;
       access_log     /var/log/apache2/domains/complexwebs.com.bytes bytes;
       expires        max;
       try_files      $uri @fallback;
   }
}

location /error/ {
   alias   /home/admin/web/complexwebs.com/document_errors/;
}

location @fallback {
   proxy_pass      http://192.168.0.39:8080;
}

location ~ /\.ht    {return 404;}
location ~ /\.svn/  {return 404;}
location ~ /\.git/  {return 404;}
location ~ /\.hg/   {return 404;}
location ~ /\.bzr/  {return 404;}

include /home/admin/conf/web/nginx.complexwebs.com.conf*;
}

server {
listen      192.168.0.39:80;
server_name cdghost.xyz www.cdghost.xyz cdghost-xyz.beta.cdg.tech;
error_log  /var/log/apache2/domains/cdghost.xyz.error.log error;

location / {
   proxy_pass      http://192.168.0.39:8080;
   location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|tif|tiff|css|js|htm|html|ttf|otf|webp|woff|txt|csv|rtf|doc|docx|xls|xlsx|ppt|pptx|odf|odp|ods|odt|pdf|psd|ai|eot|eps|ps|zip|tar|tgz|gz|rar|bz2|7z|aac|m4a|mp3|mp4|ogg|wav|wma|3gp|avi|flv|m4v|mkv|mov|mp4|mpeg|mpg|wmv|exe|iso|dmg|swf)$ {
       root           /home/admin/web/cdghost.xyz/public_html;
       access_log     /var/log/apache2/domains/cdghost.xyz.log combined;
       access_log     /var/log/apache2/domains/cdghost.xyz.bytes bytes;
       expires        max;
       try_files      $uri @fallback;
   }
}

location /error/ {
   alias   /home/admin/web/cdghost.xyz/document_errors/;
}

location @fallback {
   proxy_pass      http://192.168.0.39:8080;
}

location ~ /\.ht    {return 404;}
location ~ /\.svn/  {return 404;}
location ~ /\.git/  {return 404;}
location ~ /\.hg/   {return 404;}
location ~ /\.bzr/  {return 404;}

include /home/admin/conf/web/nginx.cdghost.xyz.conf*;
}

server {
listen      192.168.0.39:80;
server_name srv39.cdghost.xyz www.srv39.cdghost.xyz srv39-cdghost-xyz.srv39.cdghost.xyz;
error_log  /var/log/apache2/domains/srv39.cdghost.xyz.error.log error;

location /.well-known/acme-challenge {
   alias /etc/letsencrypt/.well-known/acme-challenge;
   location ~ /.well-known/acme-challenge/(.*) {
       add_header Content-Type text/plain;
   }
}

location / {
   proxy_pass      http://192.168.0.39:8080;
   location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|tif|tiff|css|js|htm|html|ttf|otf|webp|woff|txt|csv|rtf|doc|docx|xls|xlsx|ppt|pptx|odf|odp|ods|odt|pdf|psd|ai|eot|eps|ps|zip|tar|tgz|gz|rar|bz2|7z|aac|m4a|mp3|mp4|ogg|wav|wma|3gp|avi|flv|m4v|mkv|mov|mpeg|mpg|wmv|exe|iso|dmg|swf)$ {
       root           /home/admin/web/srv39.cdghost.xyz/public_html;
       access_log     /var/log/apache2/domains/srv39.cdghost.xyz.log combined;
       access_log     /var/log/apache2/domains/srv39.cdghost.xyz.bytes bytes;
       expires        max;
       try_files      $uri @fallback;
   }
}

location /error/ {
   alias   /home/admin/web/srv39.cdghost.xyz/document_errors/;
}

location @fallback {
   proxy_pass      http://192.168.0.39:8080;
}

location ~ /\.ht    {return 404;}
location ~ /\.svn/  {return 404;}
location ~ /\.git/  {return 404;}
location ~ /\.hg/   {return 404;}
location ~ /\.bzr/  {return 404;}

include /home/admin/conf/web/nginx.srv39.cdghost.xyz.conf*;
}

server {
listen      192.168.0.39:80;
server_name mlinks.ml www.mlinks.ml mlinks-ml.srv39.cdghost.xyz;
error_log  /var/log/apache2/domains/mlinks.ml.error.log error;

location /.well-known/acme-challenge {
   alias /etc/letsencrypt/.well-known/acme-challenge;
   location ~ /.well-known/acme-challenge/(.*) {
       add_header Content-Type text/plain;
   }
}

location / {
   proxy_pass      http://192.168.0.39:8080;
   location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|tif|tiff|css|js|htm|html|ttf|otf|webp|woff|txt|csv|rtf|doc|docx|xls|xlsx|ppt|pptx|odf|odp|ods|odt|pdf|psd|ai|eot|eps|ps|zip|tar|tgz|gz|rar|bz2|7z|aac|m4a|mp3|mp4|ogg|wav|wma|3gp|avi|flv|m4v|mkv|mov|mpeg|mpg|wmv|exe|iso|dmg|swf)$ {
       root           /home/admin/web/mlinks.ml/public_html;
       access_log     /var/log/apache2/domains/mlinks.ml.log combined;
       access_log     /var/log/apache2/domains/mlinks.ml.bytes bytes;
       expires        max;
       try_files      $uri @fallback;
   }
}

location /error/ {
   alias   /home/admin/web/mlinks.ml/document_errors/;
}

location @fallback {
   proxy_pass      http://192.168.0.39:8080;
}

location ~ /\.ht    {return 404;}
location ~ /\.svn/  {return 404;}
location ~ /\.git/  {return 404;}
location ~ /\.hg/   {return 404;}
location ~ /\.bzr/  {return 404;}

include /home/admin/conf/web/nginx.mlinks.ml.conf*;
}

server {
listen      192.168.0.39:80;
server_name zearch.ga www.zearch.ga zearch-ga.srv39.cdghost.xyz;
error_log  /var/log/apache2/domains/zearch.ga.error.log error;

location /.well-known/acme-challenge {
   alias /etc/letsencrypt/.well-known/acme-challenge;
   location ~ /.well-known/acme-challenge/(.*) {
       add_header Content-Type text/plain;
   }
}

location / {
   proxy_pass      http://192.168.0.39:8080;
   location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|tif|tiff|css|js|htm|html|ttf|otf|webp|woff|txt|csv|rtf|doc|docx|xls|xlsx|ppt|pptx|odf|odp|ods|odt|pdf|psd|ai|eot|eps|ps|zip|tar|tgz|gz|rar|bz2|7z|aac|m4a|mp3|mp4|ogg|wav|wma|3gp|avi|flv|m4v|mkv|mov|mpeg|mpg|wmv|exe|iso|dmg|swf)$ {
       root           /home/admin/web/zearch.ga/public_html;
       access_log     /var/log/apache2/domains/zearch.ga.log combined;
       access_log     /var/log/apache2/domains/zearch.ga.bytes bytes;
       expires        max;
       try_files      $uri @fallback;
   }
}

location /error/ {
   alias   /home/admin/web/zearch.ga/document_errors/;
}

location @fallback {
   proxy_pass      http://192.168.0.39:8080;
}

location ~ /\.ht    {return 404;}
location ~ /\.svn/  {return 404;}
location ~ /\.git/  {return 404;}
location ~ /\.hg/   {return 404;}
location ~ /\.bzr/  {return 404;}

include /home/admin/conf/web/nginx.zearch.ga.conf*;
}

server {
listen      192.168.0.39:80;
server_name getlifepost.cu.cc www.getlifepost.cu.cc getlifepost-cu-cc.srv39.cdghost.xyz;
error_log  /var/log/apache2/domains/getlifepost.cu.cc.error.log error;

location /.well-known/acme-challenge {
   alias /etc/letsencrypt/.well-known/acme-challenge;
   location ~ /.well-known/acme-challenge/(.*) {
       add_header Content-Type text/plain;
   }
}

location / {
   proxy_pass      http://192.168.0.39:8080;
   location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|tif|tiff|css|js|htm|html|ttf|otf|webp|woff|txt|csv|rtf|doc|docx|xls|xlsx|ppt|pptx|odf|odp|ods|odt|pdf|psd|ai|eot|eps|ps|zip|tar|tgz|gz|rar|bz2|7z|aac|m4a|mp3|mp4|ogg|wav|wma|3gp|avi|flv|m4v|mkv|mov|mpeg|mpg|wmv|exe|iso|dmg|swf)$ {
       root           /home/admin/web/getlifepost.cu.cc/public_html;
       access_log     /var/log/apache2/domains/getlifepost.cu.cc.log combined;
       access_log     /var/log/apache2/domains/getlifepost.cu.cc.bytes bytes;
       expires        max;
       try_files      $uri @fallback;
   }
}

location /error/ {
   alias   /home/admin/web/getlifepost.cu.cc/document_errors/;
}

location @fallback {
   proxy_pass      http://192.168.0.39:8080;
}

location ~ /\.ht    {return 404;}
location ~ /\.svn/  {return 404;}
location ~ /\.git/  {return 404;}
location ~ /\.hg/   {return 404;}
location ~ /\.bzr/  {return 404;}

include /home/admin/conf/web/nginx.getlifepost.cu.cc.conf*;
}

server {
listen      192.168.0.39:80;
server_name truos.ga www.truos.ga truos-ga.srv39.cdghost.xyz;
error_log  /var/log/apache2/domains/truos.ga.error.log error;

location /.well-known/acme-challenge {
   alias /etc/letsencrypt/.well-known/acme-challenge;
   location ~ /.well-known/acme-challenge/(.*) {
       add_header Content-Type text/plain;
   }
}

location / {
   proxy_pass      http://192.168.0.39:8080;
   location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|tif|tiff|css|js|htm|html|ttf|otf|webp|woff|txt|csv|rtf|doc|docx|xls|xlsx|ppt|pptx|odf|odp|ods|odt|pdf|psd|ai|eot|eps|ps|zip|tar|tgz|gz|rar|bz2|7z|aac|m4a|mp3|mp4|ogg|wav|wma|3gp|avi|flv|m4v|mkv|mov|mp4|mpeg|mpg|wmv|exe|iso|dmg|swf)$ {
       root           /home/admin/web/truos.ga/public_html;
       access_log     /var/log/apache2/domains/truos.ga.log combined;
       access_log     /var/log/apache2/domains/truos.ga.bytes bytes;
       expires        max;
       try_files      $uri @fallback;
   }
}

location /error/ {
   alias   /home/admin/web/truos.ga/document_errors/;
}

location @fallback {
   proxy_pass      http://192.168.0.39:8080;
}

location ~ /\.ht    {return 404;}
location ~ /\.svn/  {return 404;}
location ~ /\.git/  {return 404;}
location ~ /\.hg/   {return 404;}
location ~ /\.bzr/  {return 404;}

include /home/admin/conf/web/nginx.truos.ga.conf*;
}

您的問題發生是因為您沒有使用正確的縮進並且沒有將伺服器塊分離到單獨的文件中,以便您可以啟用和禁用配置以進行測試。

無論如何,nginx 實際上會告訴您問題出在哪裡。nginx: [emerg] "location" directive is not allowed here in /home/admin/conf/web/nginx.conf:100

:100部分錶示第 100 行。如果您檢查文件的第 100 行,您會看到您有以下塊。

location ~ /\.ht    {return 404;}
location ~ /\.svn/  {return 404;}
location ~ /\.git/  {return 404;}
location ~ /\.hg/   {return 404;}
location ~ /\.bzr/  {return 404;}

include /home/admin/conf/web/nginx.globalcdg.ga.conf*;
} # <---- You're closing the server block here.

# Looks like you're missing the opening server block here.
   location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|tif|tiff|css|js|htm|html|ttf|otf|webp|woff|txt|csv|rtf|doc|docx|xls|xlsx|ppt|pptx|odf|odp|ods|odt|pdf|psd|ai|eot|eps|ps|zip|tar|tgz|gz|rar|bz2|7z|aac|m4a|mp3|mp4|ogg|wav|wma|3gp|avi|flv|m4v|mkv|mov|mp4|mpeg|mpg|wmv|exe|iso|dmg|swf)$ {
       root           /home/admin/web/lifepost.site/public_html;
       access_log     /var/log/apache2/domains/lifepost.site.log combined;
       access_log     /var/log/apache2/domains/lifepost.site.bytes bytes;
       expires        max;
       try_files      $uri @fallback;
   }
}

location /error/ {
   alias   /home/admin/web/lifepost.site/document_errors/;
}

location @fallback {
   proxy_pass      http://192.168.0.39:8080;
}

location ~ /\.ht    {return 404;}
location ~ /\.svn/  {return 404;}
location ~ /\.git/  {return 404;}
location ~ /\.hg/   {return 404;}
location ~ /\.bzr/  {return 404;}

include /home/admin/conf/web/nginx.lifepost.site.conf*;
} # <--- this ends the partial server block.

引用自:https://serverfault.com/questions/750643