After updating Custombuilt Nginx will not start

maartsurf

New member
Joined
Aug 12, 2016
Messages
4
Hi There,

I've a serious issue on my Centos server with DirectAdmin installed. The Nginx webserver is failing to start after an update 30 minutes ago. Hope there's someone that can help! I get the following message in the terminal:
Code:
● nginx.service - The nginx HTTP and reverse proxy server
   Loaded: loaded (/etc/systemd/system/nginx.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Wed 2019-05-01 10:46:34 CEST; 16s ago
  Process: 17435 ExecStartPre=/usr/sbin/nginx -t -c /etc/nginx/nginx.conf (code=exited, status=1/FAILURE)

May 01 10:46:34 server....nl systemd[1]: Starting The nginx HTTP and reverse proxy server...
May 01 10:46:34 server....nl nginx[17435]: nginx: [emerg] "server" directive is not allowed here in /usr/local/directadmin/data/users/admin/nginx.conf:34
May 01 10:46:34 server....nl nginx[17435]: nginx: configuration file /etc/nginx/nginx.conf test failed
May 01 10:46:34 server....nl systemd[1]: nginx.service: control process exited, code=exited status=1
May 01 10:46:34 server....nl systemd[1]: Failed to start The nginx HTTP and reverse proxy server.
May 01 10:46:34 server....nl systemd[1]: Unit nginx.service entered failed state.
May 01 10:46:34 server....nl systemd[1]: nginx.service failed.
I see "nginx: [emerg] "server" directive is not allowed here in /usr/local/directadmin/data/users/admin/nginx.conf:34" what should I change to make it work again?

Thanks in advance!
 

zEitEr

Super Moderator
Joined
Apr 11, 2005
Messages
13,853
Location
GMT +7.00
Hello,

It seems you added a "server" into a wrong CUSTOm section under customization in Directadmin.
Or your templates are corrupted.
 

maartsurf

New member
Joined
Aug 12, 2016
Messages
4
Hello,

It seems you added a "server" into a wrong CUSTOm section under customization in Directadmin.
Or your templates are corrupted.
Hi Alex,

I'm sorry to come back to your reply this late. Unfortunately I'm still not able to update Nginx and PHP. I've tried to edit the nginx.conf file but I obviously do not know what I'm doing since the error keeps showing up. The following lines are added to the nginx.conf file in the admin folder:
Code:
location /
       {
               rewrite ^.*/files/(.*)$ /wp-includes/ms-files.php?file=$1 last;
               if (!-e $request_filename) {
                       rewrite  ^(.+)$  /index.php?q=$1  last;
               }
       }
server {
    location = /xmlrpc.php {
        deny all;
    }
(where server is the error line #34)

Can you please point me in the right direction so I can solve this issue? My PHP version isn't supported anymore so I really need to update, also I want to know what I'm doing so maybe you can give me a link to resources where I can learn more on editing nginx.conf files in DA?

Thanks in advance,

Maarten
 

maartsurf

New member
Joined
Aug 12, 2016
Messages
4
Hi Alex,

So I just can remove the last CUSTOM4 (the xmlrpc code). And then start with your tutorial? The code I have in my /usr/local/directadmin/data/templates/custom/nginx_server.conf file looks like this:
|CUSTOM1|
|?DOCROOT=`HOME`/domains/`DOMAIN`/public_html|
|?REALDOCROOT=`HOME`/domains/`DOMAIN`/public_html|
|?OPEN_BASEDIR_PATH=`HOME`/:/tmp:/var/tmp:/usr/local/lib/php/|
server
{
|CUSTOM|

listen |IP|:|PORT_80|;
|MULTI_IP|

server_name |DOMAIN| www.|DOMAIN| |SERVER_ALIASES|;

access_log /var/log/nginx/domains/|DOMAIN|.log;
access_log /var/log/nginx/domains/|DOMAIN|.bytes bytes;
error_log /var/log/nginx/domains/|DOMAIN|.error.log;


root |DOCROOT|;

index index.php index.html index.htm;

|NGINX_PHP_CONF|

|*if HAVE_NGINX_PROXY="1"|
location /
{
|CUSTOM2|
|LOCATION_INSERT|
# access_log off;
proxy_buffering |PROXY_BUFFERING|;
proxy_pass http://|IP|:|PORT_8080|;
proxy_set_header X-Client-IP $remote_addr;
proxy_set_header X-Accel-Internal /nginx_static_files;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /nginx_static_files/
{
# access_log /var/log/nginx/access_log_proxy;
alias |DOCROOT|/;
internal;
}
|*else|
|NGINX_REDIRECTS|
|PROTECTED_DIRECTORIES|
|EXTRA_LOCATIONS|
|*endif|

|CUSTOM3|

include /etc/nginx/webapps.conf;
|*if HAVE_NGINX_PROXY!="1"|
location /
{
rewrite ^.*/files/(.*)$ /wp-includes/ms-files.php?file=$1 last;
if (!-e $request_filename) {
rewrite ^(.+)$ /index.php?q=$1 last;
}
}
|*endif|

|CUSTOM4|
server {
location = /xmlrpc.php {
deny all;
}
}
I assume I've messed this up since I'm just another simple "tutorial-follower". But I really want to learn what I'm doing here so perhaps you can show me what to change in this file and give me some tips on how and where to start learning how these custom posts work in DA? Or would it be a better idea just to start with a training on the basics of webserver (nginx/apache) administration?

Thanks in advance for getting back to me,

Maarten
 

maartsurf

New member
Joined
Aug 12, 2016
Messages
4
Thanks again for the help Alex! I've cleaned my /usr/local/directadmin/data/templates/custom/nginx_server.conf file and updating wasn't an issue anymore after that. Now I'm going to follow your tutorial for server wide blocking access to xmlrpc.php. Would like to learn the basics so meanwhile I'm starting a Nginx, Apache and SSL certification training :D.
 
Top