【发布时间】:2020-09-24 11:52:11
【问题描述】:
我想在我的服务器中部署我的 laravel 应用程序,使用 nginx 作为 apache 的反向代理,我遇到了以 index.php 开头的 URL 和页面链接的问题。我尝试了没有 index.php 的 url,它可以工作,但是页面中的所有链接都带有 index.php。这是我的配置:
Nginx:
server {
listen 80;
server_name dev.exemple.com;
root /var/www/laravel-app/public/;
index index.php index.htm index.html;
location / {
try_files $uri $uri/ /index.php$uri;
}
location ~ \.php {
proxy_pass http://MY-SERVER-IP-ADDRESS:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location ~ /\. {
deny all;
}
location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
access_log off;
expires max;
log_not_found off;
}
}
阿帕奇
<VirtualHost *:8080>
ServerName dev.exemple.com
DocumentRoot /var/www/laravel-app/public/
<Directory /var/www/laravel-app/>
AllowOverride All
</Directory>
</VirtualHost>
【问题讨论】:
标签: laravel apache nginx deployment nginx-reverse-proxy