dptt66700 2015-06-29 19:35
浏览 197

在Nginx中包含子目录的配置

For example, I have a webserver for testing.

Now I put Drupal 8 in a Subdirectory.

The server config in Nginx is OK for plain php files, but Drupal needs another config because of URL scheme.

My goal is something like this:

normal.cfg

server {
   listen 80;
   server_name _;

   location (phpfiles) {
      pass to PHPFPM;
   }
}

drupal_test.cfg

server {
   listen 80;
   server_name _;

   location /drupal/(phpfiles) {
      do_some_magic
      pass to PHPFPM;
   }
}

But then Nginx complains about ignoring duplicated server_name.

So, how can I include a specific (separated file) configuration for a given subdirectory of a given server_name that I can later delete without much problems? This is because I don't want to mess up the main config.

  • 写回答

1条回答 默认 最新

  • dsfsdf7852 2015-06-29 19:55
    关注

    the probably most common way of doing this is to include a separate file for every virtual server. you can either include a specific file with

    include /path/of/configfile;
    

    or choose the common way by using a wildcard:

    include /etc/nginx/sites-enabled/*;
    

    in both cases you have to put this line in the http direcitve of your nginx config file.

    评论

报告相同问题?

悬赏问题

  • ¥15 制裁名单20240508芯片厂商
  • ¥20 易康econgnition精度验证
  • ¥15 线程问题判断多次进入
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接