1

Allow me to explain my problem. I have a Ubuntu VPS server running 18.04 I have installed Nginx and Apache with php-fpm I've configured Nginx to be a reverse proxy for my wordpress blog located at https://mydomainname.com/blog this is all working fine. however I have been unable to get my permalinks to work my config for my server block:



server {
        listen 80;
        return 301 https://%host$request_uri;
}
server {
    listen 443 ssl;
    root /var/www/mydomain.com/;


    server_name mydomain.com www.mydomain.com;


ssl_certificate /etc/letsencrypt/live/mydomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mydomain.com/privkey.pem;


 ssl on;
    ssl_session_cache  builtin:1000  shared:SSL:10m;
    ssl_protocols  TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
    ssl_prefer_server_ciphers on;

access_log            /var/log/nginx/site.access.log;



    location /blog/ {
        index index.php index.html index.htm;
        try_files $uri $uri/ /blog/index.php?q=$uri&$args =404;



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

  # Fix the “It appears that your reverse proxy set up is broken" error.
      proxy_pass          http://127.0.0.1:8080;
      proxy_read_timeout  90;


        proxy_redirect off;

    }

}




My Apache Vhost configuration:

<VirtualHost 127.0.0.1:8080>
    ServerName mydoamin.com
    ServerAlias www.mydomain.com
    DocumentRoot /var/www/mydomain.com
<FilesMatch "\.php$">
   SetHandler "proxy:unix:///var/run/php7.2-fpm-mydomain.sock|fcgi://127.0.0.1/"
</FilesMatch>

    <Directory /var/www/mydomain.com>
        Options Indexes FollowSymLinks MultiViews

      Require all granted
        AllowOverride All
    </Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
      CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>


my .htaccess file



<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>


any help is appreciated.

  • return 301 https://%host$request should % not an dollar? – djdomi Jan 25 at 17:31
  • I tried that and it did not work – dbjoe Jan 25 at 19:37
  • you really needs to put more output what does not work – djdomi Jan 26 at 19:19
  • please give us more output – djdomi Jan 31 at 12:20
0

I have now resolved this. The problem was I had forgotten to enable Mod-ReWrite for Apache. I've also updated my Nginx Conf to be:


server {
        listen 80;
        return 301 https://$host$request_uri;
}
server {
    listen 443 ssl;
    root /var/www/mydomain.com/;
    #index index.html index.htm index.php;

    server_name mydomain.com www.mydomain.com;


ssl_certificate /etc/letsencrypt/live/mydomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mydomain.com/privkey.pem;


 ssl on;
    ssl_session_cache  builtin:1000  shared:SSL:10m;
    ssl_protocols  TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
    ssl_prefer_server_ciphers on;

access_log            /var/log/nginx/mydomain.access.log;


location / {
return 301 https://$host/blog/;
}

    location /blog/ {
        index index.php index.html index.htm;

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

  # Fix the “It appears that your reverse proxy set up is broken" error.
      proxy_pass          http://127.0.0.1:8080;
      proxy_read_timeout  90;


        proxy_redirect off;

    }

}



| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.