Hot answers tagged

92

Nginx configuration files don't 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 line. (Source.) If you have between 30 and 50 lines to ditch out I'd suggest to remove the block entirely (after making a copy of the file), to avoid confusion....


57

I assume its a Linux box, so most likely SELinux is preventing the connection as there is no policy allowing the connection. You should be able to just run # setsebool -P httpd_can_network_connect true and then restart nginx.


50

The process you noticed is the master process, the process that starts all other nginx processes. This process is started by the init script that starts nginx. The reason this process is running as root is simply because you started it as root! You can start it as another user, but you will have to make sure that all resources nginx needs are available to ...


39

I insert disable_symlinks off; in my nginx.conf and i resolved, works fine! http { disable_symlinks off; }


35

From the documentation: src, path of the file to link to (applies only to state=link). Will accept absolute, relative and nonexisting paths. Relative paths are not expanded. You need to use src and dest when using state=link, not path. You also need to invert your source and destination, which appear to be the wrong way around (assuming that you really ...


33

The problem is with the nss package being too old. This older version cannot talk with the Fedora site via curl which uses an older version of the nss library. Just update your nss version to the latest, it solves the problem with the EPEL repo update: $ sudo yum clean all $ sudo yum --disablerepo="epel" update nss NOTE: this version of nss-3.14.3-4....


26

A similar issue was reported on Debian bug #754407. In the end it was just the port 80 being taken by other process (Apache2). Might this be your case as well?


26

Yes, I'm pretty sure you would need to reload Nginx in order for the renewed certificates to display the correct expiration date, but a simple cache-clearing and browse should allow you to view this. Or if you prefer cli, you could always use the old trusty OpenSSL command: echo | openssl s_client -connect your.domain.com:443 | openssl x509 -noout -dates ...


25

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://ip_of_the_app:7180/; proxy_redirect http://ip_of_the_app:7180/ http://$host/sales/; } This allows you to host the /sales/ path somewhere else. But even ...


21

You seem to confuse enable, start and mask operations. systemctl start, systemctl stop: starts (stops) the unit in question immediately; systemctl enable, systemctl disable: marks (unmarks) the unit for autostart at boot time (in a unit-specific manner, described in its [Install] section); systemctl mask, systemctl unmask: disallows (allows) all and any ...


21

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 configuration. If it happens that nginx can't read some SSL certificates, I'll continue to run using older configuration. Otherwise put, it'll continue to function and ...


20

If the following fails: yum check-update but: yum --disablerepo="epel" check-update works, then run: URLGRABBER_DEBUG=1 yum check-update 2> debug.log and check debug.log for: PYCURL ERROR 77 - "Problem with the SSL CA cert (path? access rights?)" If this message is found, then try: yum --disablerepo="epel" reinstall ca-certificates If that ...


20

Stop apache2 service apache2 stop then install nginx apt-get install nginx Then celebrate it!


19

When you are getting permission denied errors on file access etc. for unknown reason, it might be related to SELinux. Especially when you see a period following permissions like drwxr-xr-x. shown by ls -l for the file/dir in question, they could be mislabeled (you can see it by ls -Z) and cause the problem. You should first check current SELinux mode by ...


17

Most servers (Apache, Nginx, etc.) have a parent process that's owned by root which then forks copies of worker nodes up using a less credentialed user. In this case it's www-data. Example If you take a look at nginx's config file, /etc/nginx/nginx.conf, you'll notice lines like this: user nginx; worker_processes 2; #change to the number of your CPUs/...


16

This SO Q&A sounds like it might be your issue, titled: nginx showing blank PHP pages. Your location stanza should look similar to this: location ~ \.php$ { include /path/to/fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /path/to/www/dir$fastcgi_script_name; } You have to pay ...


14

Nginx does not have the right to read the users files. And it's a very bad idea to put all your users files available on the Web. A better idea is to only serve a dedicated directory in users home directory. To serve the www folder in each user folder when accessing /<USER>, use the following location: location ~ ^/(.+?)(/.*)?$ { alias /home/$1/...


13

This might be useful to others facing this problem, You also can add into your nginx conf file fastcgi_params the following line, so you don't need to specify path to the variable SCRIPT_FILENAME fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; This is very handy specially when you have many virtual hosts.


13

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.10.0 on 2016-04-26), nginx did gain support for doing TCP stream proxying, which means that if you have a recent-enough version of nginx, you can, in fact, ...


13

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; server_name $server ; root /usr/share/nginx/html; } EOF fi the syntax cat <<EOF is called a "here document". $server will be replace by its value, or ...


11

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 from the Headers More module like this: more_set_headers 'Set-Cookie: $sent_http_set_cookie; secure'; Both of these can introduce problems because they ...


10

The sudo part just starts the rest with root priviliges. The manual pages for service say that service SCRIPT COMMAND executes a System V init script located in /etc/init.d/SCRIPT or, in case of the system using Upstart, an upstart job in /etc/init. If you have both: The existence of an upstart job of the same name as a script in /etc/init.d will ...


9

Nginx responds to the USR1 signal by reopening its log files. The USR1 signal kills a program by default, but it's meant to be handled to do whatever the program finds useful. Each program defines what it does with USR1 and USR2; for Nginx, that's reopening the log files (for log rotation) and executing a new instance (for upgrades). By convention, most ...


9

Your goal is to completely separate your "regular" web files from your phpMyAdmin installation. It should be stressed that each server configuration in Nginx can (and should) have only one webroot. That being said, these are your options: Install phpMyAdmin in a directory under your webroot, which in your case is /var/www/phpmyadmin. It can be accessed ...


9

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 ip in browser and it worked


9

The post rotate action appears to be incorrect Try invoke-rc.d nginx reload >/dev/null 2>&1 If you look at the nginx command you will see the actions it will accept. Also the message you got says check initctl --help xtian@fujiu1404:~/tmp$ initctl help Job commands: start Start job. stop Stop ...


9

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.pem; ssl_certificate_key /etc/letsencrypt/live/myexample.org/privkey.pem; ssl_stapling on; ssl_stapling_verify on; See here for further context.


9

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 expressions. Thus, files like .htaccess, .htpasswd, etc, will not be served. Note: The backslash (\) before the dot, is just to escape the dot (the dot that ...


9

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 that you're not adding an additional point of failure (that you can control). You've no longer got to maintain and update a monitoring service


8

The issue seems to be you are using an unprivileged user to test the Nginx configuration. When the test occurs, it attempts to create /run/nginx.pid, but fails and this causes the configuration test to fail. Try running nginx as root. $ sudo nginx -t or $ su - -c "nginx -t" This way, the Nginx parent process will have the same permission it would when ...


Only top voted, non community-wiki answers of a minimum length are eligible