SatelliteWP / rocket-nginx

Rocket-Nginx is a Nginx configuration that makes WP-Rocket even faster by serving static pages directly without loading WordPress or PHP.
MIT License
579 stars 129 forks source link

Rocket-Nginx is not working as expected in our multisite WordPress #191

Closed vvinodhkannan closed 1 year ago

vvinodhkannan commented 1 year ago

Hi Team, our multisite wordpress is running in this https://qawp.example.com/blogswordpress/. We have configured nginx for wp rocket as per the document https://github.com/SatelliteWP/rocket-nginx . After the wp-rocket nginx configuration we cant access our multisite wordpress. Mentioned the site urls below. And attached the nginx site configuration and we used this(https://github.com/SatelliteWP/rocket-nginx/blob/master/rocket-nginx.tmpl) wprocket nginx configuration.

We are suspecting the issue with wprocket nginx config.

we need wprocket nginx config as per our wordpress url which we installed immediate next url to our domain (https://qawp.example.com/blogswordpress/).

Expecting you response asap.

https://qawp.example.com/blogswordpress/about https://qawp.example.com/blogswordpress/careers

Note: Again we mention here, we have installed multisite worpress in this url(https://qawp.example.com/blogswordpress). And installed our js site in the main domain (https://qawp.example.com)

Below is our nginx config

ssl_session_cache shared:SSL:10m; ssl_session_timeout 10m; server { listen 80; listen [::]:80; server_name example.com; return 301 https://example.com$request_uri; gzip on; gzip_disable "msie6"; gzip_vary on; gzip_proxied any; gzip_comp_level 6; gzip_buffers 16 8k; gzip_http_version 1.1; gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; }server { listen 443 ssl default_server; listen [::]:443 ssl default_server;

    access_log /var/log/nginx/qawp_access.log;
    error_log /var/log/nginx/qawp_error.log;
   ssl_certificate /home/ubuntu/star_example_com.pem;
   ssl_certificate_key /home/ubuntu/example.key;
   ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

    gzip on;
    gzip_disable "msie6";

    gzip_vary on;
    gzip_proxied any;
    gzip_comp_level 6;
    gzip_buffers 16 8k;
    gzip_http_version 1.1;
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
server_name example.com;
    keepalive_timeout  70;
    add_header Content-Security-Policy "default-src https: data: was: 'unsafe-inline' 'unsafe-eval'" always;
    add_header Strict-Transport-Security "max-age=31536000; includeSubdomains" always;
    #add_header X-Frame-Options "SAMEORIGIN" always;
    add_header X-Frame-Options "ALLOW-FROM https://alphath.example.co.in";
    add_header X-Xss-Protection "1; mode=block" always;
    add_header X-Content-Type-Options "nosniff" always;
   location /blogswordpress {
         root /var/www/html;
   try_files $uri $uri/ @blogswordpress;
    index index.php;
 location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/run/php/php7.2-fpm.sock;
    fastcgi_send_timeout 300;
    fastcgi_read_timeout 300;
    }
include rocket-nginx/conf.d/default.conf;
}
location @blogswordpress {
    rewrite /blogswordpress/(.*)$ /blogswordpress/index.php?/$1 last;
}
if (!-e $request_filename) {
            rewrite /wp-admin$ $scheme://$host$uri/ permanent;
            rewrite ^/blogswordpress(/[^/]+)?(/wp-.*) /blogswordpress$2 last;
            rewrite ^/blogswordpress(/[^/]+)?(/.*\.php)$ /blogswordpress$2 last;
    }
location / {
        proxy_pass http://127.0.0.1:3002;
        root /home/ubuntu/ssr/example-ssr-prod/.next;      
}
    location ~ /_next/(.*)$ {
        proxy_pass http://127.0.0.1:3002;
        root /home/ubuntu/ssr/example-ssr-prod/.next;
    }
location  ~* ^\/[a-zA-Z0-9_-]+\.xml$ {
  root /home/ubuntu/ssr/static/sitemap;
   }
   error_page 404 https://example.com;
            try_files $uri $uri/ =404;  
    #proxy configurations
    location /v1 {
        proxy_pass http://appserver.example.com:2345;
    }
    location /v2 {
        proxy_pass http://appserver.example.com:2345;
    }
    location /v3 {
        proxy_pass http://appserver.example.com:2345;
    }
     location /geoip {
        proxy_pass http://django.example.com:8000;
    }
    location /finalprice {
        proxy_pass http://django.example.com:8000;
    add_header Pragma public;
add_header Cache-Control " public, max-age=31536000, no-transform, no-cache, must-revalidate";
add_header Access-Control-Allow-Origin *;
    }
    location /collection {
        proxy_pass http://django.example.com:8000;
    }
    location /builder-city {
        set $upstream http://sailsapi.example.com:1337;
        proxy_pass $upstream;
    }
    location /tickets {
       set $freshdesk https://examplecom.freshdesk.com/api/v2/;
       proxy_pass $freshdesk;
    }
 location /api {
        proxy_pass https://example.com;
    }
 location /ksl-email {
        proxy_pass http://10.0.20.123:9090;
    }
     location /ksl-api {
        proxy_pass http://appserver.example.com:9091;
    }
location /microsite {
    client_max_body_size 16M;
    proxy_pass http://microsite.example.com/microsite;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header Host $host;
    add_header X-Content-Type-Options "nosniff";

} }

maximejobin commented 1 year ago

Rocket-Nginx was created to work at the server block level. It seems you've included it inside a location block.

I was not able to replicate the issue. Your configuration is really specific so I recommend you get in touch with a Nginx expert to help you debug that specific situation and give more information about the issue.

Please activate debug and submit the headers you are getting. Otherwise, it's almost impossible to understand what the problem is. Thank you.