Sites
Custom nginx configuration
Add your own nginx lines to a site's server block — WebSockets, pretty URLs, redirects, headers, timeouts — and see what Zefily writes around them.
On servers running nginx, the site's Custom nginx pane adds your own lines to the site's server block. It is not a full configuration file: Zefily writes the whole site file itself, and only the lines you enter are yours. On OpenLiteSpeed servers, see Custom OpenLiteSpeed configuration.
Many common needs are already buttons in the site's Access and Rules panes: canonical host, password protection, allowed addresses, maintenance mode, redirects, response headers, CORS, error pages, restricted paths, blocked addresses and countries. On a WordPress site, the XML-RPC and PHP-in-uploads filters are there too. Use those first: Zefily keeps them when it changes the site. Use custom nginx for what they do not cover.
What Zefily writes
Zefily writes the site's whole server block, and it changes it when you change the site:
- the server names (the domain and its aliases), the listening ports and the HTTPS certificate,
- the web root, the index files and the site's logs,
- the handler for the site: its own PHP pool for PHP sites, or the proxy to its app for Node, Python and container sites,
- the page cache, the web application firewall, the built-in protection (hidden dotfiles and backup files, security headers, 30-day caching of static files) and the Access and Rules settings.
Your lines go inside that server block: server-level lines after Zefily's own server-level lines (headers, the upload limit, the cache and the firewall), and location blocks before Zefily's PHP or app locations. Two rules follow from how nginx works:
- A
location /of your own (or@appfor app sites) replaces Zefily's default one, so you can change how unknown paths are handled. - A
locationwith its ownadd_headerdoes not inherit the site'sadd_headerlines, so Zefily repeats its managed headers in that location for you:X-Content-Type-Options,Referrer-Policy,Strict-Transport-Securityon HTTPS, and the headers set under Access and Security headers. A header your location sets itself is left as you wrote it.
Static files (CSS, JavaScript, images, fonts) have a default location that comes before yours, so a plain location /assets/ does not change their caching. Write location ^~ /assets/ instead: ^~ stops nginx from checking the pattern rules for that path first.
Add directives
- Open the site and choose Custom nginx.
- Write your directives in the editor, or start from an example: WebSockets, Pretty URLs, Large uploads, Redirect, Security headers.
- Click Apply and approve with your passkey.
Zefily checks your lines first, then nginx tests the whole site file (nginx -t) before it goes live. If a check fails, the previous configuration stays active and the pane says why. Leave the editor empty and apply to remove your directives.
Examples
These are the examples the checks accept as written.
WebSockets to an app listening on a local port (Laravel Reverb, Socket.IO…):
location /app {
proxy_pass http://127.0.0.1:8080;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 3600s;
}
Pretty URLs (every unknown path goes to index.php):
location / {
try_files $uri $uri/ /index.php?$args;
}
Larger uploads and a longer PHP request time:
client_max_body_size 512m;
fastcgi_read_timeout 600s;
An old path that moves (a 301 redirect):
rewrite ^/old-blog/(.*)$ /blog/$1 permanent;
The www address to the plain domain (add www.example.com as an alias of the site first; the Canonical host setting in Access does the same without a line):
if ($host = www.example.com) {
return 301 https://example.com$request_uri;
}
Block PHP files in an uploads folder:
location ~* /uploads/.*\.php$ {
deny all;
}
Browser caching of a folder for a year (the ^~ keeps the default static-file rule from winning):
location ^~ /assets/ {
expires 1y;
}
Let one address into a folder:
location /admin/ {
allow 203.0.113.7;
deny all;
}
What is allowed
Your lines run inside nginx, which runs as root, so only directives that stay within the site are accepted. These are the ones the checks accept:
- Locations and conditions:
location,if. - Rewrites and responses:
rewrite,return,try_files,set,error_page,index,autoindex,internal,charset,default_type,absolute_redirect,port_in_redirect,server_name_in_redirect. - Headers and caching:
add_header,add_trailer,expires,etag,if_modified_since. - Access:
allow,deny,satisfy,log_not_found,access_log(onlyaccess_log off; the site's log stays where Zefily keeps it). - Reverse proxy:
proxy_passto a target on this server or its private network (see Proxy targets below), withproxy_set_header,proxy_http_version,proxy_read_timeout,proxy_send_timeout,proxy_connect_timeout,proxy_buffering,proxy_buffers,proxy_buffer_size,proxy_busy_buffers_size,proxy_request_buffering,proxy_redirect,proxy_cache_bypass,proxy_no_cache,proxy_hide_header,proxy_pass_header,proxy_intercept_errors,proxy_ssl_server_name,proxy_cookie_path,proxy_cookie_domain,proxy_max_temp_file_size,proxy_next_upstream. - PHP:
fastcgi_passonly to the site's own PHP pool, andfastcgi_param,fastcgi_read_timeout,fastcgi_send_timeout,fastcgi_buffers,fastcgi_buffer_size,fastcgi_busy_buffers_size,fastcgi_intercept_errors,fastcgi_split_path_info,fastcgi_index,fastcgi_hide_header,fastcgi_request_buffering. - Limits:
client_max_body_size,client_body_timeout,client_header_timeout,client_body_buffer_size,keepalive_timeout,send_timeout,large_client_header_buffers,limit_rate,limit_rate_after. - Compression and transfer:
gzip,gzip_types,gzip_vary,gzip_min_length,gzip_comp_level,gzip_proxied,chunked_transfer_encoding,sendfile,tcp_nopush,tcp_nodelay. - Content:
sub_filter,sub_filter_once,sub_filter_types,merge_slashes.
Proxy targets
A target is one of these:
- a literal IP address, on this server or anywhere public, with or without a port (the port defaults to 80 for
http://and 443 forhttps://):proxy_pass http://127.0.0.1:6001;,proxy_pass https://203.0.113.10; - a host name, such as
https://api.example.com/v1/orhttp://backend.internal:8080. Zefily resolves it when you save: every address it has must be allowed, or the save is refused and the message names the address that is not localhost, or a unix socket in the site's own home:proxy_pass http://unix:/home/<user>/<path>.sock:/;
Refused: link-local addresses (169.254.0.0/16, fe80::/10, where the cloud metadata service lives), the unspecified address (0.0.0.0, ::), multicast addresses, host names that do not resolve, and variables such as $host in the target.
nginx also resolves a host name when it loads the configuration, so a name that later points at a refused address is refused at the next apply, and the site keeps its previous configuration. A socket that links out of the site's home after you saved is left out of the site's configuration at the next apply, and the event is logged.
What is refused
The pane names the first line it refuses. These are the directives that are refused, and what to use instead:
| Directive | Why it is refused | Instead |
|---|---|---|
include, root, alias |
They read files from outside the site's own settings | Your files go in the site's web root; the root is set by Zefily |
load_module, Lua, Perl, njs blocks |
They load code into nginx | Not available |
ssl_*, certificate paths |
TLS is managed by Zefily | The site's General pane, HTTPS and certificate |
proxy_pass to a link-local, unspecified or multicast address, to a host name that does not resolve, or to a variable ($…) |
Link-local addresses (169.254.x.x, fe80::/10) hold the cloud metadata service; a variable is picked for every request | A public or private address, or a host name that resolves to an allowed address |
proxy_pass to a unix socket outside the site's home |
Could reach other services on the server, such as the Docker socket | A socket in the site's home: proxy_pass http://unix:/home/<user>/…/app.sock:/ |
add_header Strict-Transport-Security |
Zefily sends HSTS from the site's HTTPS settings | The HSTS setting in the site's HTTPS settings |
add_header Set-Cookie |
Cookies belong to the application that sets them | Set the cookie in your application |
access_log to another file |
Logs must stay in the site's logs | access_log off, or the site's Logs pane |
fastcgi_pass to another pool |
Would run PHP as another site | The site's own PHP pool is set by Zefily |
auth_basic, auth_basic_user_file |
They need a password file on the server | Access → Password-protected folders (per folder) or Password protection (whole site) |
limit_req, limit_req_zone, limit_req_status |
They need zones defined on the server | Rules → Request rate limit (whole site, or below a path) |
limit_conn, limit_except |
They need zones or method rules defined on the server | Not available yet |
set_real_ip_from, real_ip_header |
The visitor's real address is already set for every nginx site (Cloudflare) | Nothing to add |
server_tokens |
Already off on every nginx site | Nothing to add |
Any directive that is not in the allowed list is refused too. If you need one from this table that no panel feature covers, write to support with the line you need.
History and restore
Every save is kept: History under the editor lists the last 30 versions with their time, who saved them and whether they applied. Compare shows what a version changes against the current directives (− removed, + added), Load into editor puts it in the editor to adjust, and Restore applies it again through the same passkey approval and nginx test as a save. A version that nginx refuses never replaces the running configuration. A save whose passkey approval came too late is never applied: the directives stay as the last applied version, and the save stays in the history as not applied.
A location / (or @app for app sites) of your own replaces the site's default one, as described above.
Updated November 26, 2026 View as Markdown llms.txt