Docker and Apache - Redirect 301 and trailing slash -


i hope can find here because i'm little lost since days...

i'm trying put php application in docker container.

so i'm using image: https://hub.docker.com/_/php/ (especially php:7-apache tag). way have php , apache in same container.

so problem when i'm accessing url without trailing slash i've wrong redirection add slash use container ip address not accessible on docker host.

example:

  • http:// localhost/admin -> redirection problem
  • http:// localhost/admin/ -> works great

as can see in screenshot, there automatic redirection local ip of container, it's not accessible: have timeout in web browser.

console screenshot

in case container ip address 172.17.0.2

(my container published on host on port 80, i'm accessing localhost standard docker way)

my virtualhost quite simple:

<virtualhost *:*>     serveradmin webmaster@localhost      documentroot /var/www/html       errorlog ${apache_log_dir}/error.log      # possible values include: debug, info, notice, warn, error, crit,     # alert, emerg.     loglevel warn      customlog ${apache_log_dir}/access.log combined  </virtualhost> 

do have ideas problem ? think remember 301 redirection normal behavior of apache because of mod_dir ? why using container local ip ?

thanks , sorry english!

in virtual host missing below

servername localhost 

when missing apache try determine hostname , use ip instead. since runs under docker container ip 172.17.0.2 not reachable through browser.

that why adding servername required, when apache has send redirect request can create correct url of redirect


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -