Nginx+Wordpress+Letsencypt result in 403 Forbidden


#1

Hello, I am looking for clues why I can’t resolve 403 error.

My domain is:walkaboutmaps.org on Nginx on Linode VPN. I followed this tutorial and added Letsencrypt certificate to an existing Wordpress site. It continuously shows Forbidden 403 page no matter what settings I change. I’ve installed Certificates twice, last time using this link

I run Letsencrypt client as root, wordpress have 755 and 644 premissions for foiles and folders, owned by www-data, who also is running Nginx. I have multiple wordpress sites on the VPN, have not converted them to HTTP yet and they all are working fine, using the same global/wordpress.conf; and global/restrictions.conf;
I have had previously on one of the non-wordpress sites a StartSSl certificate, which has expiered and I have removed and disabled it, not sure if this can relate since the domains are different…

Also I am getting this error:
2017/04/18 16:54:49 [error] 16929#16929: *1 directory index of “/var/www/html/hosted/walkaboutmaps.org/” is forbidden, client: 107.3.185.55, server: walkaboutmaps.org, request: “GET / HTTP/2.0”, host: “walkaboutmaps.org

I’ve tried swapping Walkaboutmaps.org directory with a fresh/clean wordpress directory, same result. So, it is not word press fault? But then I can run PHP test from the inside of the site directory (https://walkaboutmaps.org/test.php) without problems… So, what is the problem?


#2

hi @localalex

how have you setup your NGINX

do you have a listener for port 443 mapped to your root directory?

If you are not sure best to paste your NGINX config as 403 servers are usually related to server settings not SSL

Andrei


#3

Hi @ahaw021, here is my Nginx config. I am new to Nginx have not tinkered with it much. Am I missing anything in the config?
indent preformatted text by 4 spaces

    user www-data;
    worker_processes auto;
    pid /run/nginx.pid;
    
    events {
    worker_connections 768;
            # multi_accept on;
    }
    
    http {

    ##
    # Basic Settings
    ##

    client_max_body_size 100m;

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    # server_tokens off;

    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;
    
    ##
    # SSL Settings
    ##

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
    ssl_prefer_server_ciphers on;

    ##
    # Logging Settings
    ##

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    ##
    # Gzip Settings
    ##

    gzip on;
    gzip_disable "msie6";

    # gzip_vary on;
    # gzip_proxied any;

    # gzip_proxied any;
    # gzip_comp_level 6;
    # gzip_buffers 16 8k;
    # gzip_http_version 1.1;
    # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

    ##
    # Virtual Host Configs
    ##

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;

    ## Block spammers and other unwanted visitors  ##
    include blockips.conf;
    }

And here is the website config file:

    server {
        listen 80;
        listen [::]:80;
        server_name walkaboutmaps.org www.walkaboutmaps.org;
        return 301 https://$server_name$request_uri;

    root /var/www/html/hosted/walkaboutmaps.org;

    index index.php;

    # Redirect all HTTP requests to HTTPS with a 301 Moved Permanently response.
    # return 301 https://$server_name$request_uri;

    # Uncoment line below when installing sertificate to Include location directive for Let's Encrypt ACME Challenge
    include global/letsencrypt-acme-challenge.conf;

    # Additional rules go here.
    include global/restrictions.conf;
    include global/wordpress.conf;
    }

     server {
     # SSL configuration

     listen 443 ssl http2;
     listen [::]:443 ssl http2;

    server_name walkaboutmaps.org www.walkaboutmaps.org;
    root /var/www/html/hosted/walkaboutmaps.org;
    include global/restrictions.conf;
    include global/wordpress.conf;

    ssl_certificate /etc/letsencrypt/live/walkaboutmaps.org/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/walkaboutmaps.org/privkey.pem;
    
    # from https://cipherli.st/
    # and https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html
    
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
    ssl_ecdh_curve secp384r1;
    ssl_session_cache shared:SSL:10m;
    ssl_session_tickets off;
    ssl_stapling on;
    ssl_stapling_verify on;
    resolver 8.8.8.8 8.8.4.4 valid=300s;
    resolver_timeout 5s;

     # Disable preloading HSTS for now.  You can use the commented out header line that includes
     # the "preload" directive if you understand the implications.
     # add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";
    add_header Strict-Transport-Security "max-age=63072000; includeSubdomains";
    add_header X-Frame-Options DENY;
    add_header X-Content-Type-Options nosniff;
    
    ssl_dhparam /etc/ssl/certs/dhparam.pem;
     }

Also, see netstat output:

tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      3492/mysqld     
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      25559/nginx -g daem
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      3474/sshd       
tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN      25559/nginx -g daem
tcp        0      0 127.0.0.1:3306          127.0.0.1:49432         ESTABLISHED 3492/mysqld     
tcp        0      0 45.33.105.126:443       107.3.185.55:54430      TIME_WAIT   -               
tcp        0      0 127.0.0.1:3306          127.0.0.1:49430         ESTABLISHED 3492/mysqld     
tcp        0      0 127.0.0.1:49432         127.0.0.1:3306          ESTABLISHED 3549/gogs       
tcp        0      0 127.0.0.1:49430         127.0.0.1:3306          ESTABLISHED 3549/gogs       
tcp6       0      0 :::80                   :::*                    LISTEN      25559/nginx -g daem
tcp6       0      0 :::3000                 :::*                    LISTEN      3549/gogs       
tcp6       0      0 :::443                  :::*                    LISTEN      25559/nginx -g daem

#4

hi @localalex

I see you have removed the redirect however if i browses to http://www.walkaboutmaps.org the redirect is still in effect.

I suggest that you restart the NGINX server and this should give you HTTP (non ssl) connectivity

Then upload a test.html file to your root and try to browse to it over SSL

If that works then the challenges are with WordPress.

I think you may need to update wordpress to server files over HTTPS.

Review: https://css-tricks.com/moving-to-https-on-wordpress/

Andrei


#5

I am unable to get the site load in http, it keeps changing to https, including with www. prefix… I even tried a brand new install of a different browser, with same result. I am beginning to think Wordpress was not meant for providing SSL support…


#6

@localalex

rather than making silly comments like “Wordpress was not meant for providing SSL support” focus on the problem at hand

there are plenty of SSL Protected Wordpress websites out there

something is redirecting your traffic from HTTP to HTTPS - you need to figure out if it’s NGINX or WordPress and once you have found out what it is reverse the behavior

Andrei


#7

I agree. I am just frustrated. Will do as you suggested.

Edit: I managed to reverse it back to http and can login into admin. I’ll continue tomorrow with a new attempt to use SSL certificate. Thanks Andrei. I’ll report here how it goes.


#8

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.