[英]using nginx reverse proxy for docker container
I am using nginx on my ubuntu machine and setup 2 laravel application using docker and one wordpress website without docker I am using nginx on my ubuntu machine and setup 2 laravel application using docker and one wordpress website without docker
I wanted to achieve is that when someone open localhost so it opens wordpress website and if someone open localhost/app1 it opens application 1 and so on.我想要实现的是,当有人打开 localhost 时,它会打开 wordpress 网站,如果有人打开 localhost/app1,它会打开应用程序 1,依此类推。
So I have created reverse proxy so that it can open my docker container application This is what I have done所以我创建了反向代理,以便它可以打开我的 docker 容器应用程序这就是我所做的
After doing so when I try to open localhost/app1 it shows 404 but it recognise its a laravel app but shows 404这样做之后,当我尝试打开 localhost/app1 它显示 404 但它识别出它是一个 laravel 应用程序但显示 404
Here is my /etc/nginx/sites-available/website file code这是我的 /etc/nginx/sites-available/website 文件代码
server{
listen 80;
server_name localhost;
root /var/www/html/wordpress;
location /app1/{
proxy_pass http://localhost:8088;
}
}
You can create a file named redirects.map
inside the nginx folder of your application and add a mapping like您可以在应用程序的 nginx 文件夹内创建一个名为redirects.map
的文件,并添加如下映射
~^localhost/app1/(.*) localhost:8089/$1;
You should change nginx configure from您应该更改 nginx 配置
server{
listen 80;
server_name localhost;
root /var/www/html/wordpress;
location /app1/{
proxy_pass http://localhost:8088;
}
}
To至
server{
listen 80;
server_name localhost;
root /var/www/html/wordpress;
location /app1 {
proxy_pass http://localhost:8088;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.