1

I have a site https://example.com running on instance 1 on AWS EC2: nginx + wildfly app server

Everything works fine. Nginx proxy passes to wildfly. Https is configured.

I would like to set up wordpress running on different EC2 instance so it is accessible via https://example.com/blog

I set up dedicated instance for wordpress and launched wordpress using docker compose as described here: https://docs.docker.com/compose/wordpress/ I configured composer so wordpress is accessible via 80 port on that instance.

I configured ngnix as following:

server {
    listen       443 ssl http2 default_server;
    listen       [::]:443 ssl http2 default_server;
    server_name  <server_name>;
    root         /usr/share/nginx/html;

    ssl_certificate "/etc/ssl/certs/<path_to_cert>/ssl-bundle.crt";
    ssl_certificate_key "/etc/ssl/certs/<path_to_cert>/private.key";
    ssl_session_cache shared:SSL:1m;
    ssl_session_timeout  10m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers HIGH:SEED:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!RSAPSK:!aDH:!aECDH:!EDH-DSS-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA:!SRP;
    ssl_prefer_server_ciphers on;

    include /etc/nginx/default.d/*.conf;

    # main site, deployed on same instance as nginx
    location / {
            proxy_pass http://127.0.0.1:8080;
    }

    # wordpress, deployed on other instance
    location /blog/ {
            proxy_pass http://<my_wordpress_instance_local_ip>/;
            proxy_set_header X-Forwarded-Proto $scheme;
    }

    error_page 404 /404.html;
        location = /40x.html {
    }
    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }
}

I installed wordpress (using direct access to it) and configured WordPress Address (URL) and Site Address (URL) to be "https://example.com/blog" both.

Now I can access admin and home page https://example.com/blog fine. But when I click to see test "Hello World" post (url: https://example.com/blog/2018/09/28/hello-world/) I get 500 Internal Server error.

I looked at wordpress docker log and found following error: "[Fri Sep 28 18:17:25.721177 2018] [core:error] [pid 308] [client :47792] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer: https://example.com/blog/ "

How can I fix that? Disclaimer: I have no big experience in nginx, not in wordpress, so sorry for maybe stupid question. I tried different options I found on the internet but all of them are either not working or describe manual wordpress setup (not via standard docker image).

UPDATES:

  1. I updated description of nginx conf: now the whole configuration is provided;

  2. My Wordpress Permalink setting is "Day and name". I tried all of them and found that if I switch to "Plain" - everything works with no error. All other settings cause error. Obviously "Plain" does not work me and I would like to proceed with something better than that.

Alex Radzishevsky
  • 3,416
  • 2
  • 14
  • 25
  • 1
    What is your Permalink setting in WordPress? Please also edit your question and add your nginx `server` directive settings in order for people to provide you a solution. – hcheung Sep 29 '18 at 05:47
  • @hcheung, thanks for the hint about Permalinks. I updated post with more info on that. Also I provided whole "server" configuraiton. – Alex Radzishevsky Sep 29 '18 at 11:16
  • I have an explanation on why the permalink is not working on my blog https://www.e-tinkers.com/2016/11/hosting-wordpress-on-raspberry-pi-part-3-setup-wordpress/ under the section "WordPress Permalinks on Nginx". Please also read the part 2 on changing the `cgi.fix_pathinfo` to 0 on php.ini. – hcheung Sep 29 '18 at 13:37

1 Answers1

0

I found that following answer fixes the issue:

https://stackoverflow.com/a/4521620/2033394

It will require to modify image though. So it is not best, but it makes everything to work fine.

Alex Radzishevsky
  • 3,416
  • 2
  • 14
  • 25