当某个位置使用root而另一个位于proxy_pass时,nginx在url / laravel中不起作用。此网址的响应是" 404 Not Found"。如果我删除网址/和/ moda,则url / laravel可以正常工作。我这样做,因为我想要地图泊坞容器。
nginx.conf文件:
server {
listen 80;
server_name local.monllar.com;
location /laravel {
root /var/www/local.monllar.com/public_html;
index index.html index.htm;
}
location / {
proxy_pass http://localhost:32768;
}
location /moda {
proxy_pass http://localhost:2222/moda;
}
}
答案 0 :(得分:1)
我找到了解决方案。这会将docker容器的ips映射到我的本地服务器名称
nginx.conf文件:
server
{
listen 80;
server_name local.monllar.com;
location / {
root /var/www/local.monllar.com/public_html;
index index.html index.htm;
}
}
server
{
listen 80;
server_name local.moda.com;
location / {
proxy_pass http://localhost:2222/moda/;
}
}
server
{
listen 80;
server_name local.laravel.com;
location / {
proxy_pass http://localhost:32768;
}
}
Mac中的/ private / etc / hosts文件
127.0.0.1 local.monllar.com
127.0.0.1 local.moda.com
127.0.0.1 local.laravel.com