Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] WordPress on CentOS 7 Linux

Amazing!!

I already had WordPress running at my CentOS 7 server.

Then I download Jetty and install haproxy and php-fpm packages.

Create a user with "adduser -s /sbin/nologin jetty" and create /run/jetty dir with:

# java -jar /usr/share/java/jetty-distribution-9.3.10.v20160621/start.jar \
     jetty.home=/usr/share/java/jetty-distribution-9.3.10.v20160621 \
     jetty.base=/run/jetty \
     --add-to-startd=http,servlet,webapp,deploy,resources,ext,fcgi,websocket

Create the /etc/systemd/system/jetty.service file:

[Unit]
Description=Jetty
After=network-online.target

[Service]
Type=simple
User=jetty
Group=jetty
ExecStart=/usr/bin/java -jar /usr/share/java/jetty-distribution-9.3.10.v20160621/start.jar jetty.home=/usr/share/java/jetty-distribution-9.3.10.v20160621 jetty.base=/run/jetty jetty.http.port=8888
ExecStop=/bin/kill ${MAINPID}
SuccessExitStatus=143

[Install]
WantedBy=multi-user.target

Finally I copy the file from
into /run/jetty/webapps/jetty-wordpress.xml

and start Jetty + php-fpm + haproxy with "systemctl start jetty" etc.

And Wordpress just works and is even faster than before!

Even "clean URLs" work (now idea how - without mod_rewrite - but they just work).

My only problem is that with Apache I had the following wp-config.php

if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)
        $_SERVER['HTTPS'] = 'on';  // works with Apache, but not Jetty

if (preg_match('/^\d+\.\d+\.\d+\.\d+$/', $_SERVER['HTTP_X_FORWARDED_FOR']))
        $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR'];

And in my /etc/haproxy/haproxy.cfg I set these 2 variables:

defaults
    mode                    http
    option http-server-close
    option forwardfor       except 127.0.0.0/8

frontend public
    bind 144.76.184.151:443 ssl crt /etc/pki/tls/certs/slova.de.pem
    reqidel ^X-Forwarded-Proto:
    reqidel ^X-Forwarded-For:
    reqadd X-Forwarded-Proto:\ https if { ssl_fc }
    default_backend jetty

backend jetty
    server domain 127.0.0.1:8888

For some reason $_SERVER['HTTPS'] = 'on'; is not picked up by Wordpress anymore (even though I print $_SERVER to /var/log/php-fpm/www-error.log and see that var being set).

Thank you
Alex


Back to the top