Add Failthrough server of a LAN IP to Nginx?

I’m trying to add my machine’s LAN IP as a ‘failthrough’ location to use in the event the main server has issues.

Lately, my main server name (i.e. https://myserver.domain.com) has been having some issues due to LetsEncrypt certs issues, so any URL running on my server using that domain name fails as well. What I want is to have Nginx automatically pass it to the machine’s IP instead if it detects the domain name itself is down.

I’m using the Docker LinuxServer LetsEncrypt container, and I’ve tried just adding the IP to the server_name variable in the config, but after restarting the container, nothing appears to change when trying to navigate to https://myserver.domain.com (it still just gives the same error page instead of redirecting to the IP).

Here’s the current config with the issue:

server {      listen 443 ssl http2 default_server;      root /config/www;     index index.php index.html index.htm;      server_name myserver.* 192.168.0.194:3333;      # enable subfolder method reverse proxy confs     include /config/nginx/proxy-confs/*.subfolder.conf;      # Tell search engines not to crawl/add this domain     add_header X-Robots-Tag "noindex, nofollow, nosnippet, noarchive";      # all ssl related config moved to ssl.conf     include /config/nginx/ssl.conf;      # enable for ldap auth     #include /config/nginx/ldap.conf;      client_max_body_size 0;      location ~ \.php$   {         fastcgi_split_path_info ^(.+\.php)(/.+)$  ;         fastcgi_pass 127.0.0.1:9000;         fastcgi_index index.php;         fastcgi_param  SCRIPT_FILENAME  $  document_root$  fastcgi_script_name;         include /etc/nginx/fastcgi_params;     } } 

Note this line in particular; the IP as the second server is the intended failthrough IP:

server_name myserver.* 192.168.0.194:3333;

Also note: if I just use https://192.168.0.194:3333 directly in a browser, it navigates to the intended page fine, so this has to be something config-wise with Nginx that I’m trying to solve. It seems like a pretty simple issue, but I’m not super familiar with Nginx config nuances yet.

Manejar locations con Nginx estilo Apache

les cuento que hace poco me muevo de Apache a NGINX y pues me entero que la forma en que manejan las URL es un poco diferente, debido a que debo corregir eso en brevedad, podria alguien mostrarme como hacer urls como estas en en el server block:

miweb.com/nombredelscript (Sin extension) miweb.com/un-titulo-web (que ejecute, por ejemplo: script2.php?titulo=$  1) miweb.com/trabajos/titulo-de-trabajo (que ejecute, por ejemplo: works.php?id=$  1) 

lo he intentado y no lo logro.

Nginx 403 Forbidden error on a simple conf file

I’ve got a new Ubuntu 18.04 droplet on DO. Just installed Nginx and Ufw (which is disabled for now) on it. I’ve this conf file inside the /etc/nginx/conf.d folder.

server {     listen 80 ;     listen [::]:80 ;          root /var/www/2;         index index.html index.htm index.nginx-debian.html;          server_name 2.hotelbobbygg.xyz;          location / {                 try_files $  uri $  uri/ =404;         } } 

I’ve also tried commenting out the 3rd line from last, i.e. try_files line. But it still behaves the same.

Pls help what is preventing me to access the index.html lying inside /var/www/2 folder.

nginx.service is not active, cannot reload. and also 503 Service Temporarily Unavailable nginx is showing. Can anyone help

I have installed wordpress through easyengine and getting this issues.

root@fn:~# journalctl -xe | grep nginx Sep 08 04:09:48 fn sudo[24157]: root : TTY=pts/0 ; PWD=/root ; USER=root ; COMMAND=/usr/bin/apt-get install python-certbot-nginx Sep 08 04:10:40 fn sudo[25139]: root : TTY=pts/0 ; PWD=/root ; USER=root ; COMMAND=/bin/nano /etc/nginx/sites-available/default Sep 08 04:11:26 fn sudo[25141]: root : TTY=pts/0 ; PWD=/root ; USER=root ; COMMAND=/bin/nano /etc/nginx/sites-available/default Sep 08 04:11:42 fn sudo[25144]: root : TTY=pts/0 ; PWD=/root ; USER=root ; COMMAND=/usr/sbin/nginx -t Sep 08 04:11:52 fn sudo[25146]: root : TTY=pts/0 ; PWD=/root ; USER=root ; COMMAND=/bin/systemctl reload nginx Sep 08 04:11:52 fn systemd[1]: nginx.service: Unit cannot be reloaded because it is inactive. Sep 08 04:11:58 fn sudo[25149]: root : TTY=pts/0 ; PWD=/root ; USER=root ; COMMAND=/bin/systemctl reload nginx Sep 08 04:11:58 fn systemd[1]: nginx.service: Unit cannot be reloaded because it is inactive. Sep 08 04:15:43 fn sudo[25156]: root : TTY=pts/0 ; PWD=/root ; USER=root ; COMMAND=/bin/systemctl start nginx — Subject: Unit nginx.service has begun start-up — Unit nginx.service has begun starting up. Sep 08 04:15:43 fn nginx[25168]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) Sep 08 04:15:43 fn nginx[25168]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use) Sep 08 04:15:43 fn nginx[25168]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) Sep 08 04:15:43 fn nginx[25168]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use) Sep 08 04:15:44 fn nginx[25168]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) Sep 08 04:15:44 fn nginx[25168]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use) Sep 08 04:15:44 fn nginx[25168]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) Sep 08 04:15:44 fn nginx[25168]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use) Sep 08 04:15:45 fn nginx[25168]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) Sep 08 04:15:45 fn nginx[25168]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use) Sep 08 04:15:45 fn nginx[25168]: nginx: [emerg] still could not bind() Sep 08 04:15:45 fn systemd[1]: nginx.service: Control process exited, code=exited status=1 Sep 08 04:15:45 fn systemd[1]: nginx.service: Failed with result ‘exit-code’. — Subject: Unit nginx.service has failed — Unit nginx.service has failed. Sep 08 04:23:57 fn sudo[25266]: root : TTY=pts/0 ; PWD=/root ; USER=root ; COMMAND=/etc/init.d/nginx start — Subject: Unit nginx.service has begun start-up — Unit nginx.service has begun starting up. Sep 08 04:23:58 fn nginx[25285]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) Sep 08 04:23:58 fn nginx[25285]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use) Sep 08 04:23:58 fn nginx[25285]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) Sep 08 04:23:58 fn nginx[25285]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use) Sep 08 04:23:59 fn nginx[25285]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) Sep 08 04:23:59 fn nginx[25285]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use) Sep 08 04:23:59 fn nginx[25285]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) Sep 08 04:23:59 fn nginx[25285]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use) Sep 08 04:24:00 fn nginx[25285]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) Sep 08 04:24:00 fn nginx[25285]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use) Sep 08 04:24:00 fn nginx[25285]: nginx: [emerg] still could not bind() Sep 08 04:24:00 fn systemd[1]: nginx.service: Control process exited, code=exited status=1 Sep 08 04:24:00 fn systemd[1]: nginx.service: Failed with result ‘exit-code’. — Subject: Unit nginx.service has failed — Unit nginx.service has failed.

Error can not start nginx

i install:

sudo apt-get install nginx

i try: sudo /etc/init.d/nginx start sudo service nginx start or

nginx -s reload

-> nothing change

root@8eef8e717289:/# nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok

nginx: configuration file /etc/nginx/nginx.conf test is successful

root@8eef8e717289:/#

root@8eef8e717289:/# sudo /etc/init.d/nginx start

How to avoid restarting nginx to renew letsencrypt certificate?

I have installed a Nginx server to host my website, and added HTTPS with LetsEncrypt.

The problem is every time the certificate expire, my site become inaccessible and I need to manually restart the service using So every two months or so I am forced to manually do a:

sudo service nginx restart 

I tried automating that several time already but failed. My last attempt was using this:

sudo crontab -e   0 0,12 * * * letsencrypt renew >/dev/null 2>&1  1 0,12 * * * root /etc/init.d/nginx reload 

Is this the wrong way? How can I validate this job works without waiting my site to be inacessible again?

NGINX acceder a multiples sitios desde la misma IP

Quisiera saber como puedo tener varios sitios en Nginx y poder acceder a cada uno de ellos con la misma IP (sin el dominio, ya que estoy haciendo pruebas en un laboratorio localmente).

El servidor lo tengo en una PC aparte y accedo remotamente desde mi computadora mediante la IP. Ambos estan en la misma red LAN

En el directorio /var/www/ tengo dos sitios ‘nextcloud’ y ‘phpmyadmin’. Quisiera poder ingresar a ambos colocando (por ejemplo) 192.168.1.14/nextcloud y 192.168.1.14/phpmyadmin. O teniendo cualquier otro proyecto en el directorio www.

Intente todas las soluciones que encontre, pero ninguna de ellas me ha funcionado. Cuando ingreso a phpmyadmin por ejemplo, me da para descargar la pagina en lugar de entrar a ella.

Dentro de /etc/nginx/sites-enabled tengo los dos archivos, uno de nextcloud:

    server {         listen 80 default_server;         listen [::]:80 default_server;          root /var/www/nextcloud/;          index  index.php index.html index.htm;          server_name  localhost;          client_max_body_size 512M;         fastcgi_buffers 64 4K;          location / {             root /var/www/nextcloud;         rewrite ^ /index.php$  request_uri;         }          location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)/ {             deny all;         }         location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) {             deny all;         }          location ~ ^/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+)\.php(?:$  |/) {             fastcgi_split_path_info ^(.+?\.php)(/.*)$  ;             include fastcgi_params;             fastcgi_param SCRIPT_FILENAME $  document_root$  fastcgi_script_name;             fastcgi_param PATH_INFO $  fastcgi_path_info;             fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;             fastcgi_intercept_errors on;             fastcgi_request_buffering off;         }          location ~ ^/(?:updater|ocs-provider)(?:$  |/) {             try_files $  uri/ =404;             index index.php;         }          location ~ \.(?:css|js|woff|svg|gif)$   {             try_files $  uri /index.php$  request_uri;             add_header Cache-Control "public, max-age=15778463";             access_log off;         }          location ~ \.(?:png|html|ttf|ico|jpg|jpeg)$   {             try_files $  uri /index.php$  request_uri;             # Optional: Don't log access to other assets             access_log off;         }     }  

Y la de phpmyadmin:

    server {         listen 80;         listen [::]:80;          root /var/www/phpmyadmin/;          # Add index.php to the list if you are using PHP         index index.php index.html index.htm index.nginx-debian.html;          server_name localhost;          location / {             # First attempt to serve request as file, then             # as directory, then fall back to displaying a 404.             try_files $  uri $  uri/ =404;         }          # pass PHP scripts to FastCGI server         #         location ~ \.php$   {             include snippets/fastcgi-php.conf;         #         #   # With php-fpm (or other unix sockets):             fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;         #   # With php-cgi (or other tcp sockets):         #   fastcgi_pass 127.0.0.1:9000;         }     }  

Probe creando dos carpetas de prueba en /var/www/ (test1 y test2), cada una de ellas con un archivo index.html dentro y modificando el archivo default de nginx, pero tampoco me ha funcionado

    server {         listen 80 default_server;         listen [::]:80 default_server;          server_name localhost;          index index.html;          location / {             return 410;  # Default root of site won't exist.         }          location /test1/ {             alias /var/www/test1/;             try_files $  uri $  uri/ =404;              # any additional configuration for non-static content         }          location /test2/ {             alias /var/www/test2/;             try_files $  uri $  uri/ =404;              # any additional configuration for non-static content         }     }  

Como habia dicho, probe distintas soluciones. Otro problema que tuve fue que solo me redireccionaba a nextcloud, aunque coloque phpmyadmin en la url. Y el anterior que ya mencione, que cuando ingreso, descarga el index.php. Muchas gracias