Nginx no longer starts. This error started happening after running out of storage. This error was not happening before, and I have not change the config. I know there are many other questions with the same error, but none of them helped.
here is my nginx config
server {
listen 80;
listen [::]:80;
server_name <domain>;
root /var/www/pterodactyl/public;
index index.html index.htm index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log off;
error_log /var/log/nginx/pterodactyl.app-error.log error;
# allow larger file uploads and longer script runtimes
client_max_body_size 100m;
client_body_timeout 120s;
sendfile off;
location ~ \.php$ {
fastcgi_split_path_info ^(. \.php)(/. )$;
fastcgi_pass unix:<php_socket>;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param PHP_VALUE "upload_max_filesize = 100M \n post_max_size=100M";
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTP_PROXY "";
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
}
location ~ /\.ht {
deny all;
}
}
Here is the output of nginx -T
nginx: [emerg] "server" directive is not allowed here in /etc/nginx/nginx.conf:1
nginx: configuration file /etc/nginx/nginx.conf test failed
CodePudding user response:
This isn't an nginx configuration file but a vhost configuration file that should be placed at the /etc/nginx/conf.d
(or /etc/nginx/sites-enabled
if you prefer that type of vhost configuration files organization; see the Difference in sites-available vs sites-enabled vs conf.d directories thread at ServerFault to find out the difference) directory. You can check the whole nginx configuration file example at the nginx GitHub mirror.
Those vhost configuration files are usually being included from the main configuration file at the http
configuration level:
http {
...
include /etc/nginx/conf.d/*.conf;
}
and the Debian-based packages (or any other packages using those sites-enabled
/sites-available
directories) have an additional line there:
http {
...
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
To find an original nginx.conf
file for your particular Ubuntu distro, download the appropriate nginx-common
package and check its contents.