lando / wordpress

The Official WordPress Lando Plugin
https://docs.lando.dev/wordpress/
GNU General Public License v3.0
13 stars 6 forks source link

Custom NGINX Rules not working in Wordpress Lando Recipe #74

Open asimongm opened 1 month ago

asimongm commented 1 month ago

Hello,

I try to add specific CORS rules, and a redirection rule (for testing the conf) in a custom nginx config on a wordpress local lando site, but it's not working, my server directives seems to be ignored. Is there something wrong on my files ?

Here is my .lando file config :

name: projectname
recipe: wordpress
config:
  php: '8.0'
  via: nginx
  webroot: web
  database: mariadb
  config:
    server: config/nginx.conf
proxy:
  appserver_nginx:
    - projectname.lndo.site
    - projectnameother.lndo.site
  pma:
    - pma.projectname.lndo.site
services:
  appserver_nginx:
    build:
      - composer install
    scanner: false
  node:
    type: node:16
    globals:
      gulp-cli: "latest"
  pma:
    type: phpmyadmin
    hosts:
      - database
tooling:
  npm:
    service: node
  node:
    service: node
  gulp:
    service: node
  yarn:
    service: node

And here is my nginx.conf file config :

# Based on https://www.nginx.com/resources/wiki/start/topics/examples/full/#nginx-conf
user              root root;  ## Default: nobody

worker_processes  auto;
error_log         "/opt/bitnami/nginx/logs/error.log";
pid               "/opt/bitnami/nginx/tmp/nginx.pid";

events {
    worker_connections  1024;
}

http {
    include       mime.types;

    default_type  application/octet-stream;

    fastcgi_buffers 16 16k;
    fastcgi_buffer_size 32k;

    #add_header 'Access-Control-Allow-Origin' '*';
    client_body_temp_path  "/opt/bitnami/nginx/tmp/client_body" 1 2;
    proxy_temp_path        "/opt/bitnami/nginx/tmp/proxy" 1 2;
    fastcgi_temp_path      "/opt/bitnami/nginx/tmp/fastcgi" 1 2;
    scgi_temp_path         "/opt/bitnami/nginx/tmp/scgi" 1 2;
    uwsgi_temp_path        "/opt/bitnami/nginx/tmp/uwsgi" 1 2;

    log_format    main '$remote_addr - $remote_user [$time_local] '
                       '"$request" $status  $body_bytes_sent "$http_referer" '
                       '"$http_user_agent" "$http_x_forwarded_for"';

    access_log    "/opt/bitnami/nginx/logs/access.log";

    sendfile           on;

    tcp_nopush         on;
    tcp_nodelay        off;

    keepalive_timeout  65;
    gzip               on;
    gzip_http_version  1.0;
    gzip_comp_level    2;
    gzip_proxied       any;
    gzip_types         text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;

    ssl_protocols      TLSv1 TLSv1.1 TLSv1.2;

    map $http_x_forwarded_proto $lando_https {
      default '';
      https on;
    }

    map $http_x_forwarded_proto $http_user_agent_https {
      default '';
      https ON;
    }

    client_max_body_size 80M;
    server_tokens off;
    include  "/opt/bitnami/nginx/conf/vhosts/*.conf";

    # HTTP Server
    server {
        # port to listen on. Can also be set to an IP:PORT
        listen  8080;

        location ~* \.(eot|otf|ttf|woff|woff2)$ {
            add_header Access-Control-Allow-Origin *;
        }

        location /status {
            stub_status on;
            access_log   off;
            allow 127.0.0.1;
            deny all;
        }

        location /wp-content/uploads/sites/2/2020/11/Ma-Prime-Rénov-violet.pdf {
            return 301 https://www.promotelec.com/particuliers/fiche/la-renovation-a-la-cote-avec-maprimerenov/;
        }
    }
}

Thanks for helping !

reynoldsalec commented 1 month ago

@asimongm make sure the path to your nginx.conf is correct (IE in this case nested in a file config within your project root)...otherwise this looks like the correct config to me.