Is solved and the example code works out of the box… to get to the index directory of a website. I’ve tested this on my own site using a Yii framework and a Wordpress multisite setup. Unfortunately the the proxy does not seem to operate the same as our old Fly Javascript app.
After some testing I discovered that the Wordpress site needed the wordpress folders like wp-content added to the locations in the nginx.config - see the location /wp-content below.
user nginx;
worker_processes 1;
error_log /dev/stderr info;
pid /var/run/nginx.pid;
events {
worker_connections 4096;
multi_accept on;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main_ext '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" '
'"$host" sn="$server_name" '
'rt=$request_time '
'ua="$upstream_addr" us="$upstream_status" '
'ut="$upstream_response_time" ul="$upstream_response_length" '
'cs=$upstream_cache_status' ;
access_log /dev/stdout main_ext;
sendfile on;
resolver 8.8.8.8;
proxy_cache_path /tmp/nginx-cache levels=1:2 keys_zone=static:64m max_size=512m use_temp_path=off;
server {
# Origin URL
set $origin_url https://3.227.61.100;
# Hardcode host header
#set $origin_host_header example.org;
# Pass host header through
set $origin_host_header $http_host;
listen 8080 default_server;
server_name _;
port_in_redirect off;
proxy_http_version 1.1;
proxy_buffering on;
if ($http_x_forwarded_proto = "http") {
return 301 https://$http_host$request_uri;
}
location /healthz {
return 200 "ok";
}
location = / {
proxy_pass $origin_url;
proxy_ssl_protocols TLSv1.2;
proxy_ssl_server_name on;
expires off;
proxy_set_header Host $origin_host_header;
proxy_set_header Connection "";
proxy_set_header X-Forwarded-Host $http_host;
proxy_ignore_headers Vary;
add_header X-Fly-Region $http_fly_region;
add_header X-Fly-Cache $upstream_cache_status;
proxy_cache static;
proxy_cache_use_stale updating error timeout http_429 http_500 http_502 http_503 http_504;
proxy_cache_revalidate on;
proxy_cache_background_update on;
proxy_cache_lock on;
proxy_connect_timeout 2000ms;
proxy_read_timeout 30000ms;
proxy_send_timeout 30000ms;
proxy_cache_key $scheme://$http_host/$request_uri;
}
location /wp-content {
proxy_pass https://3.227.61.100/wp-content/;
}
}
# health check server
server {
listen 8080;
server_name health.check;
location /healthz {
access_log /dev/stdout;
return 200 "ok";
}
}
}
This will get most of the landing page to load:
https://www.emergingbroker.com
This does not fix the issue with Wordpress using an Apache .htaccess file linking clean urls OR the other wp-includes folder, breaking the site:
https://www.emergingbroker.com/2021/02/08/hello-world/
I want to upgrade my current service to the new app in the near future but my Yii2 app runs into the same issue as nothing outside of the index.php file will load. It has a similar Apache2 mod_rewrite with .htaccess
There is no way I can possibly define every directory location on the server. Is there way to use variables in the location to link these files on the server? Why is this so much different than the old apps?
www.ariepax.com is a Yii2 app that was working through the old Fly JavaScript app, but fails with this new setup because only the index directory can be proxied without explicitly defining every directory on the server.
I appoligise if I should not create a second topic but this seems like a separate issue as the example config file works, but not for any apps using multiple directories or mod_rewrite.
-Matt