Custom Nginx Config


#1

Hi,

Just recently aware of v4, and I got lost in so many things.
I am aware that v4 is using Docker, and I have no experience prior to this so apologies for my lack of knowledge.

I usually use some custom config on my old /etc/nginx/sites-enabled/somesite.com
But since there’s no /etc/nginx. where should I write this custom config now?

And how do I restart nginx, after I add the config?
Using service nginx restart as usual didn’t give my anything but error.

Thanks


#2

According to document, it’s in /opt/easyengine/sites/example.com/config/nginx/. After that I use docker ps to see the name or ID of example.com’s nginx container. Then docker restart <ID>.

Not sure if this is only way because it’s too complicate. Too much change on ee4 haha.


#3

@sirmbhe You can place the custom configuration in /opt/easyengine/sites/example.com/config/nginx/custom.conf then use the site reload https://easyengine.io/commands/site/reload/ command to load the additional configuration that you want to add.


#4

I just added my own nginx rule by doing the following.
For me it was not able to cd to /opt/easyengine/sites/example.com/config/nginx/custom.conf because the nginx directory is some kind of symlink between your own environment and the docker environment.
I had to sudo su to be able to cd into /opt/easyengine/sites/example.com/config/nginx/ (this probably isn’t the right way to do it because of the sudo su, can somebody please explain me how to cd properly?).

From /opt/easyengine/sites/example.com/config/ you can edit the user.conf file in the custom directory by doing the following nano nano custom/user.conf. You can add new rules directly to the file like this:

# Custom Nginx configuration can be put here

return 301 $scheme://example.com;

Then I did site reload example.com but that didn’t have any effect. I had to do a site restart example.com.

After doing this all was fine.