How to locate and edit my wordpress nginx.conf file

How to locate and edit my wordpress nginx.conf file

I have my wordpress multisite subdomain installed with easyengine, but I’m having difficulty locating the right file to edit.

I need to edit nginx.conf file to make some changes to accomodate this plugin WP Multi Network by adding some top level domain to my nginx.conf, but the file I saw at /opt/easyengine/sites/example.com/config/nginx/nginx.conf does not contain some basic information below at all

server {
        listen 80 default_server;
        listen [::]:80 default_server;

        root /var/www/html;
        index index.html index.htm index.nginx-debian.html;

        server_name _;

        location / {
                try_files $uri $uri/ =404;
        }
}

Here is the content of the file /opt/easyengine/sites/example.com/config/nginx/nginx.conf

user www-data;
worker_processes auto;
worker_rlimit_nofile 100000;
pid /run/nginx.pid;

events {
    worker_connections 4096;
    multi_accept on;
}

http {
    ##
    # EasyEngine Settings
    ##

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 30;
    types_hash_max_size 2048;

    server_tokens off;
    reset_timedout_connection on;

    # Limit Request
    limit_req_status 403;
    limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;

    # Proxy Settings
    set_real_ip_from      0.0.0.0/0;
    real_ip_header  X-Forwarded-For;

    client_max_body_size 100m;

    ##
    # SSL Settings
    ##

    ssl_session_cache shared:SSL:20m;
    ssl_session_timeout 10m;
    ssl_prefer_server_ciphers on;
    ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

    ##
    # Basic Settings
    ##
    server_names_hash_bucket_size 4096;
    # server_name_in_redirect off;

    include mime.types;
    default_type application/octet-stream;

    ##
    # Logging Settings
    ##

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    # Log format Settings
    log_format rt_cache '$remote_addr $upstream_response_time $upstream_cache_st                                                                                        atus [$time_local] '
    '$http_host "$request" $status $body_bytes_sent '
    '"$http_referer" "$http_user_agent"';

    ##
    # Gzip Settings
    ##

    gzip on;
    gzip_disable "msie6";

    gzip_vary on;
    gzip_proxied any;
    gzip_comp_level 6;
    gzip_buffers 16 8k;
    gzip_http_version 1.1;
    gzip_types
        application/atom+xml
        application/javascript
        application/json
        application/rss+xml
        application/vnd.ms-fontobject
        application/x-font-ttf
        application/x-web-app-manifest+json
        application/xhtml+xml
        application/xml
        font/opentype
        image/svg+xml
        image/x-icon
        text/css
        text/plain
        text/x-component
        text/xml
        text/javascript;

    fastcgi_buffers 16 16k;
    fastcgi_buffer_size 32k;

    include /usr/local/openresty/nginx/conf/conf.d/main.conf;
}

What I’m basically interested is on server_name _;, so that I can add some tld name.

Am I editing the wrong file or do I have to add those information manually?

Hello @ayrne,
I just stumbled on your solution at EasyEngine + Multiple Domains Pointed at a Singe Wordpress Instance Not Quite Working, but your final recommendation seem to be for v3

/etc/nginx/sites-available/second-site.com, open it and edit this line from:

Do you have an idea of which file to edit for ee v4?

You are very close to where you need to be to add custom directives. Remember that in EEv4 nginx-proxy is used. Your main nginx.conf file does nothing more than setup the base server and include the appropriate config files for the openresty proxy server.

Look here instead - /opt/easyengine/sites/yoursite.com/config/nginx/conf.d/main.conf file. But tread lightly as the top of the file clearly states:

#Add your custom config in custom/user.conf ALL CHANGES IN THIS FILE WILL BE LOST AFTER EasyEngine Update

Checking out /opt/easyengine/sites/yoursite.com/config/nginx/custom shows the user.conf file mentioned. Remember to reload/restart your site after making any changes. I make all my server directive custom mods here.

If you are curious as to the further workings, check out the default conf files for the proxy at /opt/easyengine/services/nginx-proxy/conf.d

Thanks for your response.

That seems to be the right file for the custom files. But my input could not be validated.

I want to re-write the root file location by pointing it to another location, I first put

server {
            root /to/the/desired/file/location;
}

but the following error came up when reload the site

Reloading nginx
2020/02/27 13:12:45 [emerg] 110#110: “server” directive is not allowed here in /usr/local/openresty/nginx/conf/custom/user.conf:2
nginx: [emerg] “server” directive is not allowed here in /usr/local/openresty/nginx/conf/custom/user.conf:2
nginx: configuration file /usr/local/openresty/nginx/conf/nginx.conf test failed
Reloading php

So I removed the server directive and just entered root /to/the/desired/file/location; but the following error occured…

Reloading nginx
2020/02/27 13:14:08 [emerg] 116#116: “root” directive is duplicate in /usr/local/openresty/nginx/conf/custom/user.conf:2
nginx: [emerg] “root” directive is duplicate in /usr/local/openresty/nginx/conf/custom/user.conf:2
nginx: configuration file /usr/local/openresty/nginx/conf/nginx.conf test failed
Reloading php

Any idea on how too override the default site file root at custom/user.conf so that the site file will be served from the new file location, possibly, of another site on the same server?

What exactly I want is that, I have two sites on the same server, and I want both of them to share one file location, so, to do this, I want have to rewrite the root file location of site A to point point to root file location of site B.

I completely missed your earlier comment about this being a MULTI-SITE Wordpress. I have zero knowledge and experience configuring that type of installation.

But in working on a similar task on one of my servers that is hosting several single wordpress sites, I stumbled upon https://easyengine.io/handbook/internal/nginx-proxy/#nginx-proxy-containers. While this is concerned more with how the proxy service points incoming requests to different containers it struck me as possible that this could help you out at well. I did wind up creating a custom file in the mentioned folder, used all the standard server directives and upon restarting all worked. Again, I doubt that this is the way to do it on a WP-MU installation but just figured I would share this info anyways.

Good luck!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.