WikiDocs
WikiDocs copied to clipboard
NGINX config
Can someone please post a working NGINX config for rewrite
Thank you
My apologies, I just noticed this duplicate in closed issues
Although, I'm finding it doesn't work so hopefully someone can post a better solution..
Hi @brentonv, if you confirm that it works correctly I will include it!
Sorry @Zavy86 I was just testing it now and edited my comment ^
I'll do some more thorough testing again and let you know what I can work out, as your project is brilliant and I would really like a solution to this.
Thank you
Sorry, but I have no way to test nginx, I use apache, I hope some other user can help you.. If you can solve the problem I would appreciate if you tell us the solution!
hi, in the next version i will try to build also a nginx version ith docker. @brentonv are you using docker or a local nginx environment?
fix by @leomoon
@brentonv are you using docker or a local nginx environment?
Sorry for the delay, unfortunately I could not get this config to work with my local webserver environment
I'll paste my full config soon.
Also remember if wikidocs is at root, location should change to /
So this configuration works on a Linux with PHP
and Nginx
.
WikiDocs at root of a domain
This is my configuration that hosts WikiDocs at /var/www/wiki.local/public_html/
with wiki.local
domain.
server {
listen 80;
server_name wiki.local;
add_header Strict-Transport-Security "max-age=31536000" always;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
# no cache
add_header Last-Modified $date_gmt;
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
if_modified_since off;
expires off;
etag off;
root /var/www/wiki.local/public_html/;
index index.html index.htm index.php;
# access_log /var/log/nginx/wiki.local_access.log;
# error_log /var/log/nginx/wiki.local_error.log;
location / {
if (!-e $request_filename){
rewrite ^/(.*)$ /index.php?doc=$1 last;
}
try_files $uri $uri/ =404;
}
location ~ \.php$ {
# try_files $uri =404;
fastcgi_pass unix:/run/php/php8.1-fpm.sock;
include /etc/nginx/snippets/fastcgi-php.conf;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}
location ~ /\.ht {
deny all;
}
}
WikiDocs at wikidocs
subfolder of a domain
Use this configuration if you want to host it at wikidocs
subfolder that hosts WikiDocs at /var/www/wiki.local/public_html/wikidocs/
with wiki.local/wikidocs/
domain.
server {
listen 80;
server_name wiki.local;
add_header Strict-Transport-Security "max-age=31536000" always;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
# no cache
add_header Last-Modified $date_gmt;
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
if_modified_since off;
expires off;
etag off;
root /var/www/wiki.local/public_html/;
index index.html index.htm index.php;
# access_log /var/log/nginx/wiki.local_access.log;
# error_log /var/log/nginx/wiki.local_error.log;
location /wikidocs/ {
if (!-e $request_filename){
rewrite ^/(.*)$ /index.php?doc=$1 last;
}
try_files $uri $uri/ =404;
}
location ~ \.php$ {
# try_files $uri =404;
fastcgi_pass unix:/run/php/php8.1-fpm.sock;
include /etc/nginx/snippets/fastcgi-php.conf;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}
location ~ /\.ht {
deny all;
}
}
@brentonv were you able to make it work?
I think I'll be testing this config before long. I'll let you know if it works.
@EzequielBruni any news?
Oh, crap, right. This was a while ago, and I hardly remember. Given that I went with Bookstack, I suspect it did not work.