Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does nginxconfig.io support subpath configuration for Wordpress? #421

Open
mehdiMj-ir opened this issue Feb 17, 2023 · 4 comments
Open

Does nginxconfig.io support subpath configuration for Wordpress? #421

mehdiMj-ir opened this issue Feb 17, 2023 · 4 comments

Comments

@mehdiMj-ir
Copy link

Information

https://whatismybrowser.com/w/5DDRK4Q

Help request

How to setup a Wordpress on a subpath with nginx?

Problem

I want Nginx configuration for Wordpress on a subpath, but didn't found any.

What I have tried

I tried to serve my blog located on /var/www/blog with this configuration but I couldn't succeed, (BTW my / is reverse peroxided and serve another application).

upstream php-srv {
  server unix:/run/php/php8.1-fpm.sock;
}

server {

  listen 443 ssl http2;
  #listen 443 ssl http2;
  ssl_certificate /etc/ssl/certs/domain.pem;
  ssl_certificate_key /etc/ssl/private/domain.key;
  server_name my.domain.com;
  #add_header 'Content-Security-Policy' 'upgrade-insecure-requests';

  location = /blog/robots.txt {
    allow all;
    log_not_found off;
    access_log off;
  }

  location ~ /\. {
    deny all;
  }

  location /blog {
    try_files $uri $uri/ /blog/index.php?$args;
  }

    location ~ \.php$ {
      fastcgi_split_path_info ^(/blog)(/.*)$;
      include fastcgi_params;
      fastcgi_intercept_errors on; # off later #####
      fastcgi_pass php-srv;
  #    fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
      fastcgi_param  SCRIPT_FILENAME /var/www/blog$fastcgi_script_name;
    }

  location / {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $host;
    proxy_pass http://127.0.0.1:1081$request_uri;
    include /etc/nginx/mime.types;
  }

}

server {
  listen 80;
  server_name my.domain.com;
  return 301 https://$host$request_uri;
}

Screenshots

Here is my first try with your app:

Screenshot_20230217_232134

@mehdiMj-ir
Copy link
Author

If anyone find how to solve this problem, help this poor soul too:

https://www.digitalocean.com/community/questions/getting-404-not-found-nginx-while-trying-to-visit-wordpress-post

@TauqueerAhmad
Copy link

Clear the browser cache and cookies.
Set your permalinks.
Make a default .htaccess file.
Set up a 301 redirect.
Disable plugins and themes.
Change and update the WordPress URL in the database.
Fix the error on local servers.

@TauqueerAhmad
Copy link

I think this can help you out

@mehdiMj-ir
Copy link
Author

Clear the browser cache and cookies. Set your permalinks. Make a default .htaccess file. Set up a 301 redirect. Disable plugins and themes. Change and update the WordPress URL in the database. Fix the error on local servers.

Nginx doesn't support .htaccess, I use curl on my terminal so there is no browser or caching. BTW I already fix my path and address on wp database.

Thanks for your comment but this doesn't resolve the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants