195
votes
Accepted
Does nginx support comment blocks in configuration?
Nginx configuration files do not support comment blocks; they only accept # at the beginning of a line for a comment. You can also have a valid statement followed by a # and then a comment on the same ...
56
votes
Accepted
Do I Need to Restart Nginx if I Renew My Security Certificate(s)?
You will need to RELOAD Nginx in order for the renewed certificates to display the correct expiration date (read the clarification below and the other comments for an explanation of the difference ...
36
votes
Accepted
Nginx reverse proxy redirection
Do not set proxy_redirect to off, that is not doing what you think it is doing. proxy_redirect performs something similar to URL rewriting, for example:
location /sales/ {
proxy_pass http://...
33
votes
Do I Need to Restart Nginx if I Renew My Security Certificate(s)?
On receiving SIGHUP nginx will reload updated configuration, verify it while opening log files and reading SSL certificates, then gracefully shut down worker processes relying on previous ...
22
votes
Accepted
How to configure NGINX as a reverse proxy for different port numbers?
The ssh protocol is not based on HTTP, and, as such, cannot be proxied through the regular proxy_pass of ngx_http_proxy_module
However, recently, starting with nginx 1.9.0 (released as stable with 1....
21
votes
Accepted
Shell script: How can I write multiline content to file if the file doesn't exist?
summary : use >> to append, use [ -f file ] to test.
try
if [ ! -f myfile ]
then
cat <<EOF > myfile
server {
listen 80 default_server;
listen [::]:80 default_server;
...
20
votes
Accepted
Why is the Nginx webserver called a "reverse proxy"?
A typical "forward" proxy (commonly just called "proxy") is used to allow internal clients to reach out to external sites.
For example, a corporation may have desktop users who want to reach the ...
16
votes
Accepted
Nginx location ~ /\.ht
location ~ /\.ht {
deny all;
}
This directive tells the webserver to deny all incoming requests for any files starting with .ht in the root directory (/).
The tilde ~ tells nginx to use regular ...
15
votes
Problems to install nginx-full on debian 8
in my case I executed
sudo apt-get remove nginx* --purge
after that I installed nginx-common
sudo apt-get install nginx-common
then I installed nginx
sudo apt-get install nginx
after this I typed ...
15
votes
How to configure NGINX as a reverse proxy for different port numbers?
Since Nginx Version 1.9.0,NGINX support ngx_stream_core_module module, it should be enabled with the --with-stream.
When the stream module is enabled, it is possible to ssh protocol via a TCP proxy.
...
15
votes
Accepted
Block access to a file or location on Nginx
The config below should cause nginx to respond to the "abuse" URLs with a 404 status and a basic nginx, 404 page; all other URLs ending in .php should be proxy passed to the application/php engine as ...
13
votes
Accepted
Nginx Add Secure Flag to Cookies from proxied server
I know two ways to sorta do this, neither of them great. The first is to just abuse proxy_cookie_path like this:
proxy_cookie_path / "/; secure";
The second is to use the more_set_headers directive ...
12
votes
Configuring ulimit of `max open files` for daemonized nginx master process
It seems the problem, so to speak, was my wrong assumption that a systemd service respects the ulimit configured in /etc/security/limits.conf.
As it turns out a daemon configured via systemd does ...
12
votes
Installing Let's Encrypt on Amazon Linux 2023
I managed to get certbot installed in Amazon Linux 2023 in /opt/certbot/bin/certbot using the following commands:
sudo dnf install -y augeas-libs
sudo python3 -m venv /opt/certbot/
sudo /opt/certbot/...
11
votes
Let' encrypt - nginx - OCSP stapling
Following the standard nginx setup, you should not need to specify a ssl_trusted_certificate chain. The following should be sufficient:
ssl_certificate /etc/letsencrypt/live/myexample.org/fullchain....
11
votes
Accepted
The correct way of implementing SSL on localhost
Warning: Before you dive into the minefield of running your own Certification Authority, you may need to study the security implications!
But if you must, read on for a quick and dirty CA that will ...
10
votes
SELinux is preventing NGINX from writing via PHP-FPM
setsebool -P httpd_can_network_connect on will permanently enable the flag which should solve your problem.
10
votes
Accepted
Can't uninstall or disable nginx
Raspbian uses systemd to manage services by default, not SysV. Hence sysv-rc-conf and chkconfig having an inconsistent behaviour.
To disable nginx upon boot do:
sudo systemctl disable nginx.service
...
10
votes
Accepted
NGINX not passing all request headers to Tomcat
Headers containing underscores are considered invalid by nginx, which is why it will not pass them by default. The behaviour can be overridden by the underscores_in_headers directive. For example:
...
10
votes
Accepted
A utility to email myself if my site is down
Best bet is to use a service like uptime robot. Free tier will cover less than 50 sites, pro plan is quite cheap. It'll do a simple ping check or even HTTP status code check
The upshot of this is ...
10
votes
Why is the Nginx webserver called a "reverse proxy"?
Why is the Nginx webserver called a "reverse proxy"?
"Reverse proxy" refers to a specific function that a specific Nginx instance can take on. Other Nginx instances can be ordinary web servers, or ...
9
votes
Accepted
Nginx Log Rotation Doesn't Seem to Be Working Correctly
DAY ONE
After making the change to my /etc/logrotate.d/nginx script as I mentioned in the OP...
/var/log/nginx/*.log {
daily
size 1G
missingok
rotate 10
...
9
votes
Accepted
Let' encrypt - nginx - OCSP stapling
I found the solution based on the tutorial I found there:
cd /etc/ssl/private
wget -O - https://letsencrypt.org/certs/isrgrootx1.pem https://letsencrypt.org/certs/lets-encrypt-x1-cross-signed.pem ...
8
votes
nginx: Long filenames in directory listing
You can try fancyindex module with its fancyindex_name_length parameter to configure the filename length.
8
votes
Accepted
Updating Nginx server to 1.10 on Debian 8.4
The basic error is this (emphasis mine):
dpkg: error processing archive /var/cache/apt/archives/nginx_1.10.0-1~jessie_i386.deb (--unpack): trying to overwrite '/etc/default/nginx', which is also in ...
8
votes
Accepted
Nginx on FreeBSD: fcgiwrap.sock permission denied
The RC script is located at /usr/local/etc/rc.d/fcgiwrap.
Looking at the code, fcgiwrap_user sets the owner of the process running the daemon (default root).
You need to set fcgiwrap_socket_owner="...
8
votes
Accepted
How to resolve (40: Too many levels of symbolic links) on Ubuntu 10.04 AWS EC2 Instance
You have linked django.conf back to itself. There's no data in the file, just a reference to itself.
This command,
ln -s django.conf /etc/nginx/sites-enabled/ # Wrong
creates a symbolic link in /...
7
votes
Accepted
Installing nginx on redhat - error missing libpcre.so.0
If you're running RHEL/CentOS 7, you'll probably want the 7 packages at http://nginx.org/packages/rhel/7/x86_64/RPMS/, not the ones for RHEL 6.
7
votes
Accepted
Nginx 403 error, when nginx.conf set to serve from /websites
The error log very clearly says:
Your nginx would try to read /websites/index.html, but it can't
This is why it gives 403 error, not because of its configuration.
It is because of the 13: Permission ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
nginx × 723ubuntu × 74
centos × 74
linux × 67
debian × 64
php × 59
webserver × 51
reverse-proxy × 41
ssl × 40
permissions × 31
apache-httpd × 31
proxy × 28
docker × 23
systemd × 20
configuration × 19
wordpress × 17
openssl × 16
networking × 15
security × 15
http × 15
https × 15
ssh × 14
services × 12
selinux × 12
load-balancing × 12