nginx:[emerg] 未知指令“upstream”

nginx:[emerg] 未知指令“upstream”

我正在将 nginx 配置为反向代理。我的 nginx.conf 中有以下内容:

user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
    worker_connections 768;
}

http {

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;

    server_names_hash_bucket_size 64;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    gzip off;
    gzip_disable "msie6";

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}


mail {

    server {
        listen     localhost:110;
        protocol   pop3;
        proxy      on;
    }

    server {
        listen     localhost:143;
        protocol   imap;
        proxy      on;
    }
}

这是在站点中可用的:

<^>upstream phoenix {
        server 127.0.0.1:4000;
}<^>

server {
        listen      80;
        server_name mywebsite.com www.mywebsite.com;
}

server {
    listen 443 ssl;
    listen [::]:443 ssl;

        server_name mywebsite.com wwww.mywebsite.com;

        add_header Strict-Transport-Security "max-age=31536000";

        ssl_certificate /etc/letsencrypt/live/mywebsite.com/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/mywebsite.com/privkey.pem;

        ssl_stapling on;
        ssl_stapling_verify on;

        access_log /var/log/nginx/sub.log combined;

    root /var/www/mywebsite.com/html;

    index index.html index.php index.htm;

    location / {
                allow all;

                proxy_http_version 1.1;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header Host $http_host;
                proxy_set_header X-Cluster-Client-Ip $remote_addr;

                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";

                proxy_pass http://phoenix;
    }

        location ~ /\.ht {
                deny all;
        }

        location ~ /.well-known {
                allow all;
        }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;

        fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
    }
}

当我运行时nginx -t出现错误:

nginx: [emerg] unknown directive "<^>upstream" in /etc/nginx/sites-enabled/mywebsite.com:19
nginx: configuration file /etc/nginx/nginx.conf test failed

但是,如上所示,启用站点的内容包含在 http 块中。这里出了什么问题?

答案1

看来我需要删除<^>。

相关内容