Ffile2fix
Sign in Get started

What is a .conf file?

Nginx configuration files (nginx.conf plus site files ending in .conf) tell the Nginx web server how to listen, serve files, proxy to apps and handle HTTPS. You meet them when setting up a VPS, a reverse proxy, PHP-FPM or a Docker container.

Key facts

  • The main file is usually /etc/nginx/nginx.conf, which includes site files from /etc/nginx/conf.d/*.conf or /etc/nginx/sites-enabled/.
  • Directives end with a semicolon and are grouped in blocks such as http { }, server { } and location { }.
  • Plain text, typically a few KB; there is no per-directory override like Apache's .htaccess.
  • Changes only apply after a reload, and nginx -t checks the syntax of the whole configuration first.
  • Written by sysadmins and generated by control panels, Certbot, Docker images and hosting platforms.

How to open a .conf file

Windows

Download it via SFTP (WinSCP or FileZilla) and edit it in VS Code or Notepad++, or connect with VS Code Remote-SSH to edit it on the server.

macOS

Edit the server copy over SSH with nano, or a local Homebrew install's config, which lives under /opt/homebrew/etc/nginx/ on Apple silicon.

Linux

Run sudo nano /etc/nginx/sites-available/example.conf, then sudo nginx -t to test and sudo systemctl reload nginx to apply.

Common problems and fixes

"nginx: [emerg] unexpected "}"" or "directive is not terminated by ";""
A semicolon or brace is missing on or just before the reported line. Fix it and run sudo nginx -t until it reports 'syntax is ok'.
"nginx: [emerg] unknown directive"
The directive is misspelled, belongs to a module that is not installed, or an Apache rule was pasted in. Check the spelling and the Nginx docs for the correct directive and context.
502 Bad Gateway
Nginx cannot reach the upstream app or PHP-FPM. Check that the fastcgi_pass socket or proxy_pass address matches the running service and read /var/log/nginx/error.log.
413 Request Entity Too Large on uploads
The default client_max_body_size is 1m. Raise it in the http, server or location block, for example client_max_body_size 64m;, and reload Nginx.
Single-page app or WordPress URLs return 404 on refresh
Nginx looks for a real file at the path. Add try_files $uri $uri/ /index.html; for SPAs or try_files $uri $uri/ /index.php?$args; for WordPress.

Often converted to or from: .htaccess, Apache VirtualHost config, Caddyfile

Frequently asked questions

Where is the Nginx config file?

On most Linux installs it is /etc/nginx/nginx.conf. Run nginx -t, which prints the path of the configuration file it tested.

What is the difference between sites-available and sites-enabled?

Debian and Ubuntu packages keep site configs in sites-available and activate them with a symlink in sites-enabled. Other distributions usually load every *.conf file in conf.d instead.

Do I need to restart Nginx after changing the config?

A reload is enough: sudo systemctl reload nginx or sudo nginx -s reload. It applies the new config without dropping connections, and if the new config is invalid Nginx keeps running with the old one.

See all file types β†’ Β· Browse error fixes β†’