With cloudflare full strict ssl and nginx config. I get 404 error or its not redirected to the actual files in var/www/… But goes to root /var/www/html/
I am using cloudflare tunnel. And I followed digital ocean guide to install nginx, set cloudflare SSL with nginx
Nginx config
server {
listen 80;
listen [::]:80;
server_name wp.cloudcreatr.com;
#return 302 https://$server_name$request_uri;
}
server {
# SSL configuration
listen 443 ssl http2;
listen [::]:443 ssl http2;
ssl_certificate /etc/ssl/cert.pem;
ssl_certificate_key /etc/ssl/key.pem;
server_name wp.cloudcreatr.com;
root /var/www/wp;
index index.html index.htm index.nginx-debian.html;
location / {
try_files $uri $uri/ =404;
}
}
Enabling this gives redirect loop
#return 302 https://$server_name$request_uri
Also my cloudflare tunnel config file
tunnel: 796c6fde-bae0-476f-86d6-3dfd022d6143
credentials-file: /home/cloudcreatr/.cloudflared/796c6fde-bae0-476f-86d6-3dfd022d6143.json
ingress:
- hostname: wp.cloudcreatr.com
service: https://localhost:443
originRequest:
connectTimeout: 10s
noTLSVerify: true
- hostname: wpp.cloudcreatr.com
service: http://localhost:80
# Catch-all rule, which just responds with 404 if traffic doesn't match any of
# the earlier rules
- service: http_status:404
warp-routing:
enabled: true
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Accepted Answer
Hello,
It seems like that the Nginx server block for port 443 is missing some essential rules that are needed for WordPress websites.
For example, you should have index.php
defined in the index
list and also you need to have a location that handles all PHP requests:
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
}
location ~ /\.ht {
deny all;
}
Note that the
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
line would depend on your PHP version and FPM configuration.
Also your /
location needs to be updated to the following in order to handle the requests correctly:
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
For more information I could suggest this tutorial here:
https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-with-lemp-on-ubuntu-20-04
Hope that this helps. Best, Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.