How to save changes in nginx.conf of nginx?

SupermanInNY

Verified User
Joined
Sep 28, 2004
Messages
419
Hello all,

I need to make modification to /usr/local/directadmin/data/users/userofda1/nginx.conf

Manually, I modified it, it works fine and it does exactly what I need.
However, the changes are overwritten by DA and I lose my changes.

How do I keep the modifications?

Here you can see the DIFF between original DA's nginx.conf and my modified nginx.conf


I understand I can push these changes to the Custom HTTPD Configurations, but I'm not clear on the various sections or/and how to overwrite the changes correctly.


-----------------------------------------------------------



# diff nginx.conf.original nginx.conf.modified
< proxy_pass http://11.22.33.44:8080;
---
> proxy_pass https://127.0.0.1:3002;
45c45
< listen 11.22.33.44:443 ssl;
---
> listen 11.22.33.44:443 ssl http2;
50c50
< root /home/userda1/domains/subdomain1.maindomain.com/private_html;
---
> root /home/userda1/domains/subdomain1.maindomain.com/public_html;
58c58
< proxy_pass https://11.22.33.44:8081;
---
> proxy_pass https://127.0.0.1:3002;



I appreciate any input on a step by step on how to apply this.
 
cd /usr/local/directadmin/data/templates/custom
cp ../nginx_*.conf .

and then what?
 
server
{
listen 11.22.33.44:80;
server_name subdomain1.maindomain.com www.subdomain1.maindomain.com ;
access_log /var/log/nginx/domains/subdomain1.maindomain.com.log;
access_log /var/log/nginx/domains/subdomain1.maindomain.com.bytes bytes;
error_log /var/log/nginx/domains/subdomain1.maindomain.com.error.log;
root /home/dauser1/domains/subdomain1.maindomain.com/public_html;
index index.php index.html index.htm;
if ($http_x_forwarded_proto != 'https') {
return 301 https://$host$request_uri;
}
location /
{
# access_log off;
proxy_buffering off;
### proxy_pass http://11.22.33.44:8080; << OLD VALUE
proxy_pass https://127.0.0.1:3002; ### <<< NEW VALUE
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;
proxy_hide_header Upgrade;
}
location /nginx_static_files/
{
# access_log /var/log/nginx/access_log_proxy;
alias /home/dauser1/domains/subdomain1.maindomain.com/public_html/;
internal;
}
include /etc/nginx/webapps.conf;
}



So HOW do I remove the OLD value and replace with NEW value?
 
./build rewrite_confs
Unfortunately, this actually forces an overwrite of my changes, back to defaults.
So this did not help, but of course I appreciate the assistance.

I was thinking there is an option to create a custom_ngnix.maindomain.com.conf file that I can modify it/copy it or something and it will be used instead of the default nginx.conf, but I don't know how that works.
 
Do you need the change globally for all domains or just one particular domain?

If you need it for one domain only, creating & editing the following should work (can be done via DA GUI Custom HTTPD Configurations):
/usr/local/directadmin/data/users/user/domains/domain.com.cust_nginx

If you need it globally, creating the custom/nginx_*.conf files and then editing those newly created files with the customizations and rebuilding confs should work. Do you get any errors when you attempted this?

In another forum post, someone recommended making the file immutable, but I try to avoid this, personally.
 
I'm trying to do the same thing as OP, and having trouble. Adding the updated code to the custom NGINX conf just stacks it on top of the existing conf and breaks NGINX.
 
Back
Top