NGINX - "server" directive is not allowed here

mutantChickenHer0

I'm trying to reconfigure my NGINX install to proxy to the local ghost install.

In addition to that, I'm adding SSL (letsencrypt) but I keep getting an error.

The error I get is -

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

Here is my config

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;
        }
}

The following config works fine without any issues -

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;
    }
}

mutantChickenHer0

I was able to resolve the issue using the following config file. Looks like its good, there are a number of bugs listed for Ghost and HTTPS redirects.

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;
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

nginx: [emerg] "server" directive is not allowed here

From Dev

nginx "env" directive is not allowed here

From Dev

Can't Start Nginx: "server" directive is not allowed here

From Dev

nginx directive is not allowed here in unicorn's example nginx.conf

From Dev

"set" directive is not allowed here

From Dev

nginx: [emerg] "worker_processes" directive is not allowed here in /opt/tools/nginx/conf/nginx.conf:1

From Dev

nginx: [emerg] "location" directive is not allowed here in /etc/nginx/conf.d/default.conf:1

From Dev

500 Error on apache server - "AllowOverride not allowed here"

From Dev

500 Error on apache server - "AllowOverride not allowed here"

From Dev

Nginx Config for Cors - add_header directive is not allowed

From Dev

nginx server_name directive not working

From Dev

OpenSSH Server: Directive 'SyslogFacility' is not allowed within a Match block

From Dev

"AllowOverride not allowed here" in WAMP

From Dev

AllowOverride not allowed here

From Dev

.htaccess: LogLevel not allowed here

From Dev

variable declaration not allowed here

From Dev

Array initializer is not allowed here

From Dev

Column not allowed here error

From Dev

"AllowOverride not allowed here" in WAMP

From Dev

variable declaration not allowed here

From Dev

Is this preprocessor directive acceptable here?

From Java

Setting ssl_prefer_server_ciphers directive in nginx config

From Dev

Is it possible to change server_tokens directive not in nginx.conf?

From Dev

Is it possible to change server_tokens directive not in nginx.conf?

From Dev

Error: 'void' type not allowed here

From Dev

Apache error "AliasMatch not allowed here"

From Dev

cdef statement not allowed here for structure

From Dev

Why is variable declaration not allowed here?

From Dev

Android manifest attribute not allowed here

Related Related

  1. 1

    nginx: [emerg] "server" directive is not allowed here

  2. 2

    nginx "env" directive is not allowed here

  3. 3

    Can't Start Nginx: "server" directive is not allowed here

  4. 4

    nginx directive is not allowed here in unicorn's example nginx.conf

  5. 5

    "set" directive is not allowed here

  6. 6

    nginx: [emerg] "worker_processes" directive is not allowed here in /opt/tools/nginx/conf/nginx.conf:1

  7. 7

    nginx: [emerg] "location" directive is not allowed here in /etc/nginx/conf.d/default.conf:1

  8. 8

    500 Error on apache server - "AllowOverride not allowed here"

  9. 9

    500 Error on apache server - "AllowOverride not allowed here"

  10. 10

    Nginx Config for Cors - add_header directive is not allowed

  11. 11

    nginx server_name directive not working

  12. 12

    OpenSSH Server: Directive 'SyslogFacility' is not allowed within a Match block

  13. 13

    "AllowOverride not allowed here" in WAMP

  14. 14

    AllowOverride not allowed here

  15. 15

    .htaccess: LogLevel not allowed here

  16. 16

    variable declaration not allowed here

  17. 17

    Array initializer is not allowed here

  18. 18

    Column not allowed here error

  19. 19

    "AllowOverride not allowed here" in WAMP

  20. 20

    variable declaration not allowed here

  21. 21

    Is this preprocessor directive acceptable here?

  22. 22

    Setting ssl_prefer_server_ciphers directive in nginx config

  23. 23

    Is it possible to change server_tokens directive not in nginx.conf?

  24. 24

    Is it possible to change server_tokens directive not in nginx.conf?

  25. 25

    Error: 'void' type not allowed here

  26. 26

    Apache error "AliasMatch not allowed here"

  27. 27

    cdef statement not allowed here for structure

  28. 28

    Why is variable declaration not allowed here?

  29. 29

    Android manifest attribute not allowed here

HotTag

Archive