cache – Nginx does not cache pages on disk

I configure Nginx as a web server processing PHP via php-fpm on Ubuntu 18.04. It works very well and is fast like lightning. I'm trying to configure it to cache pages to see if performance improves again. However, I have not been able to cache it on the disk. The directory in which I specified the page registration is currently open to the world (777).

Here are some relevant snippets from my configuration files and an example of page request header:

nginx.conf:

http {
        proxy_cache_path /var/www/ma_cache levels=1:2 keys_zone=ma_cache:10m use_temp_path=off max_size=20g;
}

sites-available / mysite.conf:

server {
        proxy_buffering on;
        proxy_cache ma_cache;
        proxy_cache_valid 720h;
        proxy_ignore_headers Set-Cookie;
}

Sample answer:

content-encoding: gzip
content-type: text/html; charset=UTF-8
date: Thu, 14 Nov 2019 21:08:13 GMT
server: nginx/1.14.0 (Ubuntu)
status: 200

There must be something I do not understand or just be stupid. I hope someone can direct me in the right direction.

NGINX – URL rewriting

I can not rewrite the following URL:

https://website.org/urlCNX/Files/software/software.application?CNX=CNX&UUID=66A6DUZS7Z4L742VHZ594ZAPM9P06

at

https://website.org/url/Files/software/software.application?CNX=CNX&UUID=66A6DUZS7Z4L742VHZ594ZAPM9P06

(Note the missing "CNX" after / url)

I have currently defined the following rule in NGINX but it does not matter:

   location ~* /iComptaCNX/ {
       rewrite ^/iCompta/(.+) $1 permanent;
   }

Thank you.

Serve the Google domain verification file via nginx

To perform domain verification for google, I have to serve a file to the root of my domain. The file name is typically googleXXXXXXXXXXXXX.html (these X's are a hexagonal substring).

So I did that:

location ~* /google.+.html$ {
  alias /var/www/html/$1;
}    

Although I get a 404. I have not hard-coded the file name, but it fails even if I do it.


Please note that I know this trick / workaround:

location = /googleXXXXX.html {
  rewrite ^/(.*) $1;
  return 200 "google-site-verification: $uri";
}

But I do not want to do that because it's not a proof for the future – I want to serve the file as it is.

Nginx – Specific page rewrite on another domain, ssl warning

I have 2 websites (old-domain.com and new-domain.com), I am a site that closes old-domain.com and what to redirect to the new domain. I have therefore added the rewrite and return lines in my configuration files. The catch-all (returns 301 *) works without warning. However, when I go to a specific page (for example, old-domain.com/page-1), I receive a certificate warning:

This server could not prove that it was old-domain.com; his security certificate comes from new-domain.com. This could be due to a misconfiguration or an attacker intercepting your connection.

Both domains are on the same IP address. Here is the configuration of nginx:

New domain.conf:

server {
   listen 80;
    server_name new-domain.com;
}
server { 
    listen 433;

    server_name new-domain.com;

    ssl_certificate             new-domain.cert;
    ssl_certificate_key         new-domain.cert_key;
    ssl_client_certificate      new-domain.client_cert_key;
}

old-domain.conf:

server { 
    listen 80;
    listen 433;

    server_name old-domain.com;

    ssl_certificate             old-domain.cert;
    ssl_certificate_key         old-domain.cert_key;
    ssl_client_certificate      old-domain.client_cert_key;

    #catch all - works, but causes invalid certificate
    rewrite ^/page-1 https://new-domain.com/differnt-path/page-1-extra permanent;

    #catch all - works without warning
    return 301 https://new-domain.com;

linux – Nginx fastcgi cache in a block of different location

I'm trying to cache a different location with a different cache key box, but that does not work. The cache only works for the root location "https://serverfault.com/".

If I disable the cache for the location "https://serverfault.com/", it still does not work for another location.

Block Http:

fastcgi_cache_path /webcache/nginx levels=1:2 keys_zone=microcache:100m max_size=1000m inactive=45m use_temp_path=off;
fastcgi_cache_path /webcache/extreme levels=1:2 keys_zone=extreme:100m max_size=10400m inactive=99999m use_temp_path=off;
fastcgi_cache_key "$scheme$request_method$host$request_uri";

Server block:

location ~* "^/(20(0-1)(0-8)/)" {              
   try_files $uri $uri/ /index.php?$args;
    location ~ .php$ {
        try_files $uri = 404;
        fastcgi_split_path_info ^(.+.php)(/.+)$;
        fastcgi_pass unix:/var/opt/remi/php56/run/php-fpm/php-fpm.sock;
        fastcgi_index index.php;
        include /etc/nginx/fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_intercept_errors on;
        fastcgi_cache_key "$scheme$request_method$host$request_uri";
        fastcgi_no_cache $no_cache;
        fastcgi_cache_bypass $no_cache;
        fastcgi_cache extreme;
        fastcgi_cache_min_uses 1;
        fastcgi_cache_methods GET HEAD;
        fastcgi_cache_lock on;
        fastcgi_cache_lock_age 5s;
        fastcgi_cache_lock_timeout 5s;
        fastcgi_cache_valid 200 302 301 8760h;
        fastcgi_cache_valid 500 502 10s;
        fastcgi_cache_valid 403 404 10s;
        fastcgi_cache_use_stale updating error timeout invalid_header http_500;
        fastcgi_cache_background_update on;
        fastcgi_pass_header Set-Cookie;
        fastcgi_pass_header Cookie;

}

location / {
 try_files $uri $uri/ /index.php?$args;
}


     location ~ .php$ {
        try_files $uri = 404;
        fastcgi_split_path_info ^(.+.php)(/.+)$;
        fastcgi_pass unix:/var/opt/remi/php56/run/php-fpm/php-fpm.sock;
        fastcgi_index index.php;
        include /etc/nginx/fastcgi_params;
        fastcgi_intercept_errors on;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_no_cache $no_cache;
    fastcgi_cache_bypass $no_cache;
    fastcgi_cache microcache;
    fastcgi_cache_min_uses 1;
    fastcgi_cache_methods GET HEAD;
    fastcgi_cache_lock on;
    fastcgi_cache_lock_age 5s;
    fastcgi_cache_lock_timeout 5s;
    fastcgi_cache_valid 200 302 301 1m;
    fastcgi_cache_valid 500 502 10s;
    fastcgi_cache_valid 403 404 10s;
    fastcgi_cache_use_stale updating error timeout invalid_header http_500;
    fastcgi_cache_background_update on;
    fastcgi_pass_header Set-Cookie;
    fastcgi_pass_header Cookie;
    fastcgi_ignore_headers Cache-Control Expires Set-Cookie;


        }

Nginx Sudden "strange server response" hacked?

Hello,

We just received an alert against one of our Nginx-based servers that started downloading files with any extension, for example …. | Read the rest of https://www.webhostingtalk.com/showthread.php?t=1786800&goto=newpost

Network – NGINX Redirects Web Traffic to Web Site Backed Up by Netlify

I have a Nginx web server that redirects traffic directly to mydomain.com between:

  • WordPress site
  • Node API

Now, I want to redirect all traffic directly to the old WordPress website to a new static Web site managed by Netlify, with a URL such as purple-rain.netlify.com.

The main part of the configuration is:

server {
    listen 443;
    server_name example.com;

    # SSH stuff managed by Certbot skipped

    # What is this for?
    root "/var/www/example/httpdocs";
        index index.html index.htm index.php;
    charset utf-8;

    # Redirect everything that starts with "api" or "img" to the Node API
    # like https://example.com/api/r1/users will match this

    location ~ /(api|img) {
        proxy_pass http://localhost:45001;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }

    # Redirect to the same Node API (can I merge the two?)

    location ~ /js/react {
        proxy_pass http://localhost:45001;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }

    # This redirects everything that does not match to WordPress?

    location / {
        root /var/www/example-wp/httpdocs;
        try_files $uri $uri/ /index.php?$args;
    }

    # This redirects everything that ends with ".php" to WordPress?

    location ~* .php$ {
        root /var/www/example-wp/httpdocs;
        fastcgi_index   index.php;
        fastcgi_pass    unix:/run/php/php7.2-fpm.sock;
        include         fastcgi_params;
        fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
        fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;
    }
}

How do I change this to redirect website traffic to the new Netlify-backed website?

Make nginx listen to somthing.somthing.somthing

I am new to the web servers. I am asked to do Nginx Listen ****.***.***.
Is it possible? How can I do this?

nginx – Adding a domain name to a WordPress website managed by Vultr

I have a managed instance of WordPress on Vultr. I was able to access the website very well with its IP address. Now, after adding the domain, I can not access the website anymore. "This site is inaccessible, the IP address of the server is not found." The IP address actually redirects to the domain name.

You have the right to everything

I've changed the site URL and the URL of the house in WordPress and followed all the steps outlined in this general discussion, at https://discuss.vultr.com / discussion / 1869 / how-to-change-wordpress-homepage- url-from-ip-address-to-the-domain-name

In the Google domains, I added resource records A and AAAA.

What else did I miss?

Nginx displays the Cent OS home page instead of the nginx home page

I have recently installed nginx in Cent OS The page has loaded successfully, but the Cent OS home page appears instead of the Nginx home page. Attached photo
Home page Cent OS