2015-12-17 25 views
3

我想重新配置我的NGINX安裝代理到本地ghost安裝。NGINX - 「服務器」指令不允許在這裏

除此之外,我添加SSL(letsencrypt),但我不斷收到錯誤。

我得到的錯誤是 -

nginx -t -c /etc/nginx/sites-available/ghost 
 
nginx: [emerg] "server" directive is not allowed here in /etc/nginx/sites-available/ghost:1 
 
nginx: configuration file /etc/nginx/sites-available/ghost test failed

這裏是我的配置

server { 
 
     listen   80; 
 
     server_name domainnamehere.com; 
 
     return   301 https://$server_name$request_uri; 
 
} 
 

 
server { 
 
     listen 443; 
 
     server_name www.nonstopdev.com; 
 
     access_log  /var/log/nginx/domainnamehere.com.access.log; 
 
     error_log  /var/log/nginx/domainnamehere.com.error.log; 
 

 
     ssl on; 
 
     ssl_certificate   /etc/letsencrypt/live/domainnamehere.com/fullchain.pem; 
 
     ssl_certificate_key  /etc/letsencrypt/live/domainnamehere.com/privkey.pem; 
 

 

 
     location/{ 
 
       proxy_set_header X-Real-IP $remote_addr; 
 
       proxy_set_header Host  $http_host; 
 
       proxy_pass   http://127.0.0.1:2368; 
 
     } 
 
}

以下配置工作正常,沒有任何的起訴 -

server { 
 
    listen 80; 
 
    server_name mydomainname.com; 
 
    location/{ 
 
     proxy_set_header X-Real-IP $remote_addr; 
 
     proxy_set_header Host  $http_host; 
 
     proxy_pass   http://127.0.0.1:2368; 
 
    } 
 
}

回答

1

我能夠使用以下配置文件解決問題。 看起來很不錯,Ghost和HTTPS重定向中列出了一些錯誤。

server { 
    listen 443; 

    ssl on; 
    server_name mydomain.com www.mydomain.com; 
    ssl_certificate /etc/letsencrypt/live/mydomain.com/fullchain.pem; 
    ssl_certificate_key /etc/letsencrypt/live/mydomain.com/privkey.pem; 

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; 
    ssl_prefer_server_ciphers on; 
    ssl_ciphers AES256+EECDH:AES256+EDH:!aNULL; 

    location/{ 
     proxy_set_header  X-Real-IP $remote_addr; 
     proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for; 
     proxy_set_header  X-Forwarded-Proto $scheme; 
     proxy_set_header  Host $http_host; 
     proxy_intercept_errors on; 
     proxy_pass    http://127.0.0.1:2368; 
    } 
} 

server { 
    listen 80; 
    server_name mydomain.com; 
    return 301 https://$host$request_uri; 
} 
3

它看起來像一個不完整的配置。

正常的NGINX配置以nginx.conf文件(即/etc/nginx/nginx.conf)開頭,該文件聲明瞭用戶,進程ID和其他必要的東西,後跟一個http {}分支。通常保存在conf.d目錄中的服務器{}分支,或者通常包含在nginx.conf中該http {}分支末尾的那些分支。所以儘管它們以服務器作爲out節點開始,但並不是真的是的外部節點。它在http節點內。

如果您直接加載配置文件,可能確保它包含完整的nginx配置,包括這些缺少的部分?

+0

更新了可以工作的配置 - 但沒有SSL ... – mutantChickenHer0

相關問題