nginx: [emerg] 알 수 없는 지시문 "http"

nginx: [emerg] 알 수 없는 지시문 "http"

다음과 같은 코드를 만들려고 하면:

1. http {
2.    script
3.    server {
4.        ...
5.        location ...
6.    }
7. }

오류가 발생합니다.

nginx: [emerg] unknown directive "http" in /etc/nginx/conf.d/nginx.conf:1

코드가 다음과 같은 경우:

1. server {
2.     ...
3.     location ...
4.     script
5. }
6. server {
7.     ...
8.     location ....
9.     script
10. }

...모든 것이 안정적입니다. 내가 왜 사용할 수 없는지 아는 사람이 있습니까 http?

잘 사용하는 모든 예에서 http를 볼 수 있지만 이 오류 때문에 제대로 사용할 수 없습니다.

nginx: nginx version: nginx/1.0.10
nginx: TLS SNI support enabled
nginx: configure arguments: --prefix=/etc/nginx/ --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6

답변1

/etc/nginx/nginx.conf는 http {}가 포함된 기본 구성 파일이며, conf.d의 파일이 로드됩니다.내부에해당 블록이므로 http가 이미 존재합니다.

http 블록에 일부 구성 변수를 지정하려면 이를 래핑하는 다른 태그 없이 conf.d 파일에 넣으세요.

관련 정보