0

In my public folder, I have

$ ls public
index.php   mGSV

and

$ ls public/mGSV/
ARCHITECTURE.txt    Install         base_mgsv.php       history.php     index.php       mgsv.php        scripts         tmp
Arial.ttf       README          contact.php     html            js          sample_annotation.txt   software.php        tutorial.php
INSTALLATION        about.php       css         img         lib         sample_synteny.txt  summary.php     ws

How is it possible to access localhost/index.php and localhost/mGSV/index.php I tried the following nginx's default.conf but they both point to the same index.php file?

server {
    listen  80;

    root /usr/share/nginx/html/;
    index index.php index.html index.html;

    server_name localhost;

    location / {
        try_files $uri /index.php$is_args$args;
    }

    location /mGSV {
        try_files $uri /index.php$is_args$args;
    }

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass phpfpm:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

And my docker-compose.yml file looks like this:

nginx:
    image: nginx
    restart: always
    ports:
        - "80:80"
    links:
        - phpfpm
        - db
    volumes:    
        - ./logs/nginx-error.log:/var/log/nginx/error.log
        - ./logs/nginx-access.log:/var/log/nginx/access.log

        - ./nginx/default:/etc/nginx/conf.d/default.conf

phpfpm:
    build: php5-fpm
    restart: always
    ports:
        - "9000:9000"
    links:
        - db
    volumes:
        - ./public:/usr/share/nginx/html

db:
  image: mariadb
  restart: always
  environment:
    - MYSQL_ROOT_PASSWORD=admin
    - MYSQL_DATABASE=mgsv
    - MYSQL_USER=mgsv_user
    - MYSQL_PASSWORD=mgsvpass
  ports:
    - "3306:3306"
  volumes:
    - ./mysql/:/docker-entrypoint-initdb.d

phpmyadmin:
  image: phpmyadmin/phpmyadmin
  restart: always
  links:
    - db
  ports:
    - 8183:80
  environment:
    PMA_USER: root
    PMA_PASSWORD: admin
    PMA_ARBITRARY: 1

Thank you in advance

  • If you wanted to use a different index.php you can simply put in the path to it. – Michael Hampton Mar 28 '18 at 4:52
  • Your nginx and php in different instances. That means try_files will not work as you want. Just proxy_pass everything to php – Alexey Ten Mar 28 '18 at 5:29
  • I replaced try_files with proxy_pass in location /mGSV and got nginx_1 | nginx: [emerg] invalid number of arguments in "proxy_pass" directive in /etc/nginx/conf.d/default.conf:16. What did I miss? – user977828 Mar 28 '18 at 7:09
  • I meant fastcgi_pass. And I didn’t mean to replace it literally. – Alexey Ten Mar 28 '18 at 8:58
  • Could you please give me an example? – user977828 Mar 28 '18 at 11:00

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.