Note: The nginx error log says: 2014/10/25 10:41:35 [error] 24014#0: *4 open() "/var/www/site.com/public_html/public/test" failed (2: No such file or directory), client: 123.45.67.890, server: site.com, request: "GET /test HTTP/1.1", host: "site.com"
I figured it out. Here is something that people trying to do the same should really know. So here is my shares.
I come to a solution with the following:
server {
listen 80;
access_log /var/www/site.com/logs/nginx.access.log;
error_log /var/www/site.com/logs/nginx.error.log;
root /var/www/site.com/public_html/public;
index index.php index.html;
server_name site.com;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:8080;
}
location ~* ^.*\.php$ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:8080;
}
location ~ /\.(ht|git) {
deny all;
}
}
The first thing is, I added the proxy settings for location / {
, as else it might not send you to Apache.
The next thing I did was removing try_files
from all locations, as Apache uses .htaccess to configure this.
And that was my solution.
In this case, Your nginx is doing nothing. your all requests are passing to apache.
Is there any better solution?
My better solution is to revise the "location / " section below.
location \ {
try_files $uri $uri/ @forward_to_apache;
}
location @forward_to_apache {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:8080;
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community