2 added 244 characters in body
source | link

Got itAlmost there. The solution is first to try the static file, and go to the reverse proxy (wordpress) as a fallback:

server {
    error_log  /var/log/nginx/error.log debug;
    listen            80;
    listen       [::]:80;
    server_name ${NGINX_HOST};
    sendfile          on;
    tcp_nodelay       on;
    root /static-pages;

    location / {
        try_files $uri $uri/ /static-pages/ @proxy;
    }

    location @proxy {
        proxy_read_timeout    90;
        proxy_connect_timeout 90;
        proxy_redirect        off;
        proxy_pass http://wordpress;

        proxy_set_header      X-Real-IP $remote_addr;
        proxy_set_header      X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header      Host $http_host;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

Reference:

https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/#proxy-everything

BUT! When I try accessing / I get 403 access denied for /static-pages/index.html (which doesn't exist). How can I tell it NOT to check /index.html and just fall back to the proxy if there's no directory that matches the request?

Got it. The solution is first to try the static file, and go to the reverse proxy (wordpress) as a fallback:

server {
    error_log  /var/log/nginx/error.log debug;
    listen            80;
    listen       [::]:80;
    server_name ${NGINX_HOST};
    sendfile          on;
    tcp_nodelay       on;

    location / {
        try_files $uri $uri/ /static-pages/ @proxy;
    }

    location @proxy {
        proxy_read_timeout    90;
        proxy_connect_timeout 90;
        proxy_redirect        off;
        proxy_pass http://wordpress;

        proxy_set_header      X-Real-IP $remote_addr;
        proxy_set_header      X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header      Host $http_host;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

Reference:

https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/#proxy-everything

Almost there. The solution is first to try the static file, and go to the reverse proxy (wordpress) as a fallback:

server {
    error_log  /var/log/nginx/error.log debug;
    listen            80;
    listen       [::]:80;
    server_name ${NGINX_HOST};
    sendfile          on;
    tcp_nodelay       on;
    root /static-pages;

    location / {
        try_files $uri $uri/ /static-pages/ @proxy;
    }

    location @proxy {
        proxy_read_timeout    90;
        proxy_connect_timeout 90;
        proxy_redirect        off;
        proxy_pass http://wordpress;

        proxy_set_header      X-Real-IP $remote_addr;
        proxy_set_header      X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header      Host $http_host;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

Reference:

https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/#proxy-everything

BUT! When I try accessing / I get 403 access denied for /static-pages/index.html (which doesn't exist). How can I tell it NOT to check /index.html and just fall back to the proxy if there's no directory that matches the request?

    Post Undeleted by Moshe
    Post Deleted by Moshe
1
source | link

Got it. The solution is first to try the static file, and go to the reverse proxy (wordpress) as a fallback:

server {
    error_log  /var/log/nginx/error.log debug;
    listen            80;
    listen       [::]:80;
    server_name ${NGINX_HOST};
    sendfile          on;
    tcp_nodelay       on;

    location / {
        try_files $uri $uri/ /static-pages/ @proxy;
    }

    location @proxy {
        proxy_read_timeout    90;
        proxy_connect_timeout 90;
        proxy_redirect        off;
        proxy_pass http://wordpress;

        proxy_set_header      X-Real-IP $remote_addr;
        proxy_set_header      X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header      Host $http_host;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

Reference:

https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/#proxy-everything