Docker端口转发不会调用css和图像
我已经在docker中设置了端口概念来访问我的容器magento2到本地连接的另一个系统。
这是Docker容器设置:
docker run -it -d --name containerName -h www.myhost.net -v /var/www/html -p 3000:80 --net mynetwork --ip 172.11.0.10 --privileged myimagename
然后,执行容器:
docker exec -it containerName bin/bash
卷path/ var / www / html与卷path我写一个index.html文件和访问anoter本地连接的系统其工作正常。
hostmachineip:3000
在我的容器(/ var / www / html)中安装了magnento2之后,
然后testing它为我工作,但不叫css和图像。
hostmachineip:3000
但Magento2工作文件在主机和端口转发工作文件,因为如果我打电话hostmachineip:3000 / index.html它工作正常。
但是:如果我打电话给主机的工作文件,
hostmachineip:3000
它的redirect到正确的服务器, 用CSS和图像显示magento2主页。
远程机器 只调用CSS和图像。
configuration文件:/ etc / nginx / site-available / default(服务器172.10.0.30)
# nginx Confoguraration server { listen 80; server_name www.xxxxx.net xxxx.net; access_log /var/log/nginx/access_log; error_log /var/log/nginx/error_log; root /var/www/html; location / { index index.html index.php; try_files $uri $uri/ @handler; } # Deny access to specific directories no one # in particular needs access to anyways. location /app/ { deny all; } location /includes/ { deny all; } location /lib/ { deny all; } location /media/downloadable/ { deny all; } location /pkginfo/ { deny all; } location /report/config.xml { deny all; } # location /var/ { deny all; } # Allow only those who have a login name and password # to view the export folder. Refer to /etc/nginx/htpassword. location /var/export/ { auth_basic "Restricted"; auth_basic_user_file htpasswd; autoindex on; } # Deny all attempts to access hidden files # such as .htaccess, .htpasswd, etc... location ~ /\. { deny all; access_log off; log_not_found off; } # This redirect is added so to use Magentos # common front handler when handling incoming URLs. location @handler { rewrite / /index.php; } # Forward paths such as /js/index.php/x.js # to their relevant handler. location ~ .php/ { rewrite ^(.*.php)/ $1 last; } # my proxy Configuration # pass the PHP scripts to FPM socket location ~ \.php$ { try_files $uri =404; # fastcgi_split_path_info ^(.+\.php)(/.+)$; # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini # fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_pass unix:/run/php/php7.0-fpm.sock; #fastcgi_param SCRIPT_FILENAME /usr/share/nginx/www$fastcgi_script_name; fastcgi_param DOCUMENT_ROOT /var/www/html; fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name; # send bad requests to 404 fastcgi_intercept_errors on; include fastcgi_params; } }
Loadbalancer机器Conf文件:
upstream backend { ip_hash; server 172.10.0.30 weight=5; server 172.10.0.40 weight=2; } server { listen 80; server_name chennaihousing.net www.chennaihousing.net; location / { proxy_pass http://backend; include /etc/nginx/proxy_params; } }
包括/ etc / nginx / proxy_params文件:
proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; client_max_body_size 100M; client_body_buffer_size 1m; proxy_intercept_errors on; proxy_buffering on; proxy_buffer_size 128k; proxy_buffers 256 16k; proxy_busy_buffers_size 256k; proxy_temp_file_write_size 256k; proxy_max_temp_file_size 0; proxy_read_timeout 300;
为什么? magento 2需要php支持安装在hostmachine中,那么Remote Machine也需要同样的支持? 或任何想我想念在这个configuration? build议我如何解决这个问题。
- 如何允许来自特定IP的特定端口的传入连接
- 在运行在Docker for Windows上的Docker容器中公开的端口上没有接收到UDP通信。 如何debugging?
- Docker端口80:80 127.0.0.1
- 无法连接Jenkins jlnp奴隶到安装了使用Docker jenkins / jenkins的Centos 7 master?
- 是否有可能设置一个不同的主机端口在Docker容器的暴露端口?
- 端口转发Ubuntu – Docker
- 无法从Docker容器内访问MacOSX主机上的端口
- 托pipe在centos:centos7 docker容器上的Tomcat无法查看容器外部的网页
- 阻塞除Docker之外的端口