WordPress + Nginx is giving me a “403 forbidden” error

  • Unknown's avatar

    I am trying to setup WordPress “installed using docker image” on Nginx server.

    I run the docker image using the following docker-compose.yml file

    `
    version: “3”
    services:

    wordpress_app:
    image: wordpress:latest
    restart: always
    container_name: wordpress_app
    environment:
    WORDPRESS_DB_HOST: mysql_server:3306
    WORDPRESS_DB_USER: db_username
    WORDPRESS_DB_PASSWORD: db_password
    WORDPRESS_DB_NAME: db_name
    depends_on:
    – mysql_server
    volumes:
    – /data/wordpress_app/public_html:/var/www/html
    ports:
    – 8000:80
    – 8001:443

    mysql_server:
    image: mysql:latest
    restart: always
    container_name: mysql_server
    environment:
    MYSQL_DATABASE: db_name
    MYSQL_USER: db_username
    MYSQL_PASSWORD: db_password
    MYSQL_ROOT_PASSWORD: root_password
    volumes:
    – mysql_server_data:/var/lib/mysql

    volumes:
    mysql_server_data:

    networks:
    default:
    external:
    name: nginx-network
    `

    Now, I am trying to proxy the public domain usa.mydomain.com to localhost:8000

    server {
    listen 80;
    server_name usa.mydomin.com;

    root /var/www/html;

    access_log off;
    error_log /var/log/nginx/usa.mydomain.com-error.log;

    index index.html index.php;

    location / {
    # First attempt to serve request as file, then as directory, then fall back to displaying a 404.
    try_files $uri $uri/ /index.php?$args;
    }

    # pass the PHP scripts to FastCGI server listening on localhost:8000
    location ~ .php$ {
    fastcgi_split_path_info ^(.+.php)(/.+)$;
    fastcgi_pass localhost:8000;
    fastcgi_index index.php;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param SCRIPT_NAME $fastcgi_script_name;
    }
    }

    However, when I browse usa.mydomain.com I get

    > **403 Forbidden** nginx/1.14.0 (Ubuntu)

    How can I correct this error?

    The blog I need help with is: (visible only to logged in users)

  • Hi,

    It looks like your site is using the open-source WordPress software (from WordPress.org) but is hosted with another webhost.

    We’re only able to provide support for WordPress websites that are hosted by us here at WordPress.com. For help with a WordPress site hosted elsewhere you’ll need to ask over at the WordPress.org forums:

    https://wordpress.org/support/forums/

    Depending on the level of support that is included with your hosting plan, your webhost’s support team may also be able to assist.

    If you want to know more about the differences between WordPress.com and the open-source WordPress software you can read this article:

    WordPress.com vs. WordPress.org

  • The topic ‘WordPress + Nginx is giving me a “403 forbidden” error’ is closed to new replies.