(proxy []string, localPath string)
| 413 | } |
| 414 | |
| 415 | func (s *Server) UpdatePHPProxy(proxy []string, localPath string) { |
| 416 | newDir := Directive{ |
| 417 | Name: "location", |
| 418 | Parameters: []string{"~ [^/]\\.php(/|$)"}, |
| 419 | Block: &Block{}, |
| 420 | } |
| 421 | block := &Block{} |
| 422 | block.AppendDirectives( |
| 423 | &Directive{ |
| 424 | Name: "fastcgi_pass", |
| 425 | Parameters: proxy, |
| 426 | }, |
| 427 | &Directive{ |
| 428 | Name: "include", |
| 429 | Parameters: []string{"fastcgi-php.conf"}, |
| 430 | }, |
| 431 | &Directive{ |
| 432 | Name: "include", |
| 433 | Parameters: []string{"fastcgi_params"}, |
| 434 | }, |
| 435 | ) |
| 436 | if localPath == "" { |
| 437 | block.AppendDirectives(&Directive{ |
| 438 | Name: "set", |
| 439 | Parameters: []string{"$real_script_name", "$fastcgi_script_name"}, |
| 440 | }) |
| 441 | ifDir := &Directive{ |
| 442 | Name: "if", |
| 443 | Parameters: []string{"($fastcgi_script_name ~ \"^(.+?\\.php)(/.+)$\")"}, |
| 444 | } |
| 445 | ifDir.Block = &Block{ |
| 446 | Directives: []IDirective{ |
| 447 | &Directive{ |
| 448 | Name: "set", |
| 449 | Parameters: []string{"$real_script_name", "$1"}, |
| 450 | }, |
| 451 | &Directive{ |
| 452 | Name: "set", |
| 453 | Parameters: []string{"$path_info", "$2"}, |
| 454 | }, |
| 455 | }, |
| 456 | } |
| 457 | block.AppendDirectives( |
| 458 | ifDir, |
| 459 | &Directive{ |
| 460 | Name: "fastcgi_param", |
| 461 | Parameters: []string{"SCRIPT_FILENAME", "$document_root$real_script_name"}, |
| 462 | }, |
| 463 | &Directive{ |
| 464 | Name: "fastcgi_param", |
| 465 | Parameters: []string{"SCRIPT_NAME", "$real_script_name"}, |
| 466 | }, |
| 467 | &Directive{ |
| 468 | Name: "fastcgi_param", |
| 469 | Parameters: []string{"PATH_INFO", "$path_info"}, |
| 470 | }) |
| 471 | |
| 472 | } else { |
no test coverage detected