在其中一条路线上使用angular4应用程序和wordpress博客的nginx配置

时间:2018-03-08 10:39:57

标签: php wordpress angular nginx centos7

  

假设:

应用程序正在https://example.com上运行[来自/home/centos/projects/dist.example.com的静态服务]

我正在尝试运行https://example.com/blogs来提供wordpress博客应用程序。

  

以下是我的nginx配置

    server {
    server_name example.com;

    root /home/centos/projects/dist.example.com;
    index  index.html;

    access_log /home/centos/log/example/access.log;
    error_log /home/centos/log/example/error.log;

    location / {
       try_files $uri /index.html;
       expires -1;
       add_header  Cache-Control public;
    }

    location /download {
      proxy_pass http://127.0.0.1:7000/api/downloads/;
    }

    location /blogs {
        try_files $uri $uri/ /blogs/index.php?q=$uri&$args;
        location ~ \.php$ {
        try_files $uri /index.php = 404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
         }
    }

    location ~ /\.ht {
        deny all;
    }

    ##
    # `gzip` Settings
        #
    #
    gzip on;
        gzip_disable "msie6";

        gzip_vary on;
        gzip_proxied any;
        gzip_comp_level    6;
        gzip_buffers 16 8k;
        gzip_http_version 1.1;
        gzip_min_length    256;
        gzip_types
            application/atom+xml
            application/javascript
            application/json
            application/rss+xml
            application/vnd.ms-fontobject
            application/x-font-ttf
            application/x-web-app-manifest+json
            application/xhtml+xml
            application/xml
            font/opentype
            image/svg+xml
            image/x-icon
            text/css
            text/plain
            text/javascript
            text/x-component;
}

我正在以root身份运行我的nginx,并且在许可模式下设置centos linux。 我成功运行了example.com但是当我尝试运行example.com/blogs时,它给出了nginx错误403 forbideed

  下面的

是我的php-fpm conf

的一部分
user = centos
; RPM: Keep a group allowed to write in log dir.
group = centos

;listen = 127.0.0.1:9000
listen = /var/run/php-fpm.sock

listen.owner = root
listen.group = root
;listen.mode = 0660

我没有得到我面临的许可问题

1 个答案:

答案 0 :(得分:1)

我得到了这个问题的答案

  location  /blog { 
     resolver 8.8.8.8; 
     proxy_pass https://betablog.example.com;
     if ($request_method !~ ^(GET|HEAD|POST)$ ){
        return 444;
    }
  }

在wp-config.php中更改配置,将网站名称更改为http://example.com/blogs