Nginx proxy pass php index problemsHelp needed setting up nginx to serve static filesBlank Page: wordpress on...

Finding the number of integers that are a square and a cube at the same time

Eww, those bytes are gross

Can I retract my name from an already published manuscript?

Is the theory of the category of topological spaces computable?

Avoiding morning and evening handshakes

Why is c4 a better move in this position?

Why zero tolerance on nudity in space?

Why does the DC-9-80 have this cusp in its fuselage?

What is Crew Dragon approaching in this picture?

For Loop and Sum

Why is my solution for the partial pressures of two different gases incorrect?

Wanted: 5.25 floppy to usb adapter

Proof by Induction - New to proofs

How to acknowledge an embarrassing job interview, now that I work directly with the interviewer?

What is the purpose of easy combat scenarios that don't need resource expenditure?

Finding an integral using a table?

Has the Isbell–Freyd criterion ever been used to check that a category is concretisable?

How to mitigate "bandwagon attacking" from players?

Can a person refuse a presidential pardon?

Metadata API deployments are failing in Spring '19

How to define a macro with multiple optional parameters?

Auto Insert date into Notepad

Why is working on the same position for more than 15 years not a red flag?

Is there a way to help users from having to clicking emails twice before logging into a new sandbox



Nginx proxy pass php index problems


Help needed setting up nginx to serve static filesBlank Page: wordpress on nginx+php-fpmTrouble with nginx and serving from multiple directories under the same domainnginx redirect issue with upstream configurationphpmyadmin having problems on nginx and php-fpm on RHEL 6Nginx subversion commit failureNGINX don't parse .php5 as .phpLaravel 4.1 on nginx routes error 404nginx rewrite throw 404 with last and breakNGINX virtual host config for Magento2 in a subfolder













0















I am having slight issues making my indexes work with nginx serving static content and passing php to apache on a different server.



Basically if I need it to try index.php on the backend apache server when xxx.co.uk/ is requested. If no index.php or index.html exists on the nginx server i get 403 Forbidden. If i request xxx.co.uk/index.php behaviour is as expected and apache serves the page.



Could anyone suggest a solution to this? My initial thoughts was using try_files - but exactly how I am unsure - my tinkering didn't work!



I hope I have been clear, if not then please ask and I will try to elaborate further.



Nginx settings:



server
{
listen 80;
server_name www.xxx.co.uk xxx.co.uk;
access_log /srv/www/xxx.co.uk/logs/access.log;
error_log /srv/www/xxx.co.uk/logs/error.log;

root /srv/www/xxx.co.uk/public_html;

index index.php index.html;

# deny access to apache .htaccess files
location ~ /.ht
{
deny all;
}

location ~* ^.*.php$ {

proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://192.168.0.6:80;
}
}


and apache:



 <VirtualHost 192.168.0.6:80>
ServerAdmin webmaster@xxx.co.uk
ServerName xxx.co.uk
ServerAlias xxx.co.uk www.xxx.co.uk
DocumentRoot /srv/www/xxx.co.uk/public_html/
ErrorLog /srv/www/xxx.co.uk/logs/error.log
CustomLog /srv/www/xxx.co.uk/logs/access.log combined
DirectoryIndex index.php
</VirtualHost>









share|improve this question














bumped to the homepage by Community 12 hours ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • I should also note if I place a blank index.php on the nginx server, it will work as required. The blank nginx index.php is ignored and the apache2 index.php is served. However this isn't ideal as I don't want to have to place blank 'dummy' files in every directory.

    – Chris B
    May 25 '13 at 18:59
















0















I am having slight issues making my indexes work with nginx serving static content and passing php to apache on a different server.



Basically if I need it to try index.php on the backend apache server when xxx.co.uk/ is requested. If no index.php or index.html exists on the nginx server i get 403 Forbidden. If i request xxx.co.uk/index.php behaviour is as expected and apache serves the page.



Could anyone suggest a solution to this? My initial thoughts was using try_files - but exactly how I am unsure - my tinkering didn't work!



I hope I have been clear, if not then please ask and I will try to elaborate further.



Nginx settings:



server
{
listen 80;
server_name www.xxx.co.uk xxx.co.uk;
access_log /srv/www/xxx.co.uk/logs/access.log;
error_log /srv/www/xxx.co.uk/logs/error.log;

root /srv/www/xxx.co.uk/public_html;

index index.php index.html;

# deny access to apache .htaccess files
location ~ /.ht
{
deny all;
}

location ~* ^.*.php$ {

proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://192.168.0.6:80;
}
}


and apache:



 <VirtualHost 192.168.0.6:80>
ServerAdmin webmaster@xxx.co.uk
ServerName xxx.co.uk
ServerAlias xxx.co.uk www.xxx.co.uk
DocumentRoot /srv/www/xxx.co.uk/public_html/
ErrorLog /srv/www/xxx.co.uk/logs/error.log
CustomLog /srv/www/xxx.co.uk/logs/access.log combined
DirectoryIndex index.php
</VirtualHost>









share|improve this question














bumped to the homepage by Community 12 hours ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • I should also note if I place a blank index.php on the nginx server, it will work as required. The blank nginx index.php is ignored and the apache2 index.php is served. However this isn't ideal as I don't want to have to place blank 'dummy' files in every directory.

    – Chris B
    May 25 '13 at 18:59














0












0








0








I am having slight issues making my indexes work with nginx serving static content and passing php to apache on a different server.



Basically if I need it to try index.php on the backend apache server when xxx.co.uk/ is requested. If no index.php or index.html exists on the nginx server i get 403 Forbidden. If i request xxx.co.uk/index.php behaviour is as expected and apache serves the page.



Could anyone suggest a solution to this? My initial thoughts was using try_files - but exactly how I am unsure - my tinkering didn't work!



I hope I have been clear, if not then please ask and I will try to elaborate further.



Nginx settings:



server
{
listen 80;
server_name www.xxx.co.uk xxx.co.uk;
access_log /srv/www/xxx.co.uk/logs/access.log;
error_log /srv/www/xxx.co.uk/logs/error.log;

root /srv/www/xxx.co.uk/public_html;

index index.php index.html;

# deny access to apache .htaccess files
location ~ /.ht
{
deny all;
}

location ~* ^.*.php$ {

proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://192.168.0.6:80;
}
}


and apache:



 <VirtualHost 192.168.0.6:80>
ServerAdmin webmaster@xxx.co.uk
ServerName xxx.co.uk
ServerAlias xxx.co.uk www.xxx.co.uk
DocumentRoot /srv/www/xxx.co.uk/public_html/
ErrorLog /srv/www/xxx.co.uk/logs/error.log
CustomLog /srv/www/xxx.co.uk/logs/access.log combined
DirectoryIndex index.php
</VirtualHost>









share|improve this question














I am having slight issues making my indexes work with nginx serving static content and passing php to apache on a different server.



Basically if I need it to try index.php on the backend apache server when xxx.co.uk/ is requested. If no index.php or index.html exists on the nginx server i get 403 Forbidden. If i request xxx.co.uk/index.php behaviour is as expected and apache serves the page.



Could anyone suggest a solution to this? My initial thoughts was using try_files - but exactly how I am unsure - my tinkering didn't work!



I hope I have been clear, if not then please ask and I will try to elaborate further.



Nginx settings:



server
{
listen 80;
server_name www.xxx.co.uk xxx.co.uk;
access_log /srv/www/xxx.co.uk/logs/access.log;
error_log /srv/www/xxx.co.uk/logs/error.log;

root /srv/www/xxx.co.uk/public_html;

index index.php index.html;

# deny access to apache .htaccess files
location ~ /.ht
{
deny all;
}

location ~* ^.*.php$ {

proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://192.168.0.6:80;
}
}


and apache:



 <VirtualHost 192.168.0.6:80>
ServerAdmin webmaster@xxx.co.uk
ServerName xxx.co.uk
ServerAlias xxx.co.uk www.xxx.co.uk
DocumentRoot /srv/www/xxx.co.uk/public_html/
ErrorLog /srv/www/xxx.co.uk/logs/error.log
CustomLog /srv/www/xxx.co.uk/logs/access.log combined
DirectoryIndex index.php
</VirtualHost>






nginx reverse-proxy index directoryindex






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked May 25 '13 at 18:52









Chris BChris B

134




134





bumped to the homepage by Community 12 hours ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 12 hours ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • I should also note if I place a blank index.php on the nginx server, it will work as required. The blank nginx index.php is ignored and the apache2 index.php is served. However this isn't ideal as I don't want to have to place blank 'dummy' files in every directory.

    – Chris B
    May 25 '13 at 18:59



















  • I should also note if I place a blank index.php on the nginx server, it will work as required. The blank nginx index.php is ignored and the apache2 index.php is served. However this isn't ideal as I don't want to have to place blank 'dummy' files in every directory.

    – Chris B
    May 25 '13 at 18:59

















I should also note if I place a blank index.php on the nginx server, it will work as required. The blank nginx index.php is ignored and the apache2 index.php is served. However this isn't ideal as I don't want to have to place blank 'dummy' files in every directory.

– Chris B
May 25 '13 at 18:59





I should also note if I place a blank index.php on the nginx server, it will work as required. The blank nginx index.php is ignored and the apache2 index.php is served. However this isn't ideal as I don't want to have to place blank 'dummy' files in every directory.

– Chris B
May 25 '13 at 18:59










1 Answer
1






active

oldest

votes


















0














You need a try_files and a location to put it in.



Example:



location / {
try_files $uri $uri/ =404;
}





share|improve this answer
























  • Not had chance to try yet, when I do I will feedback and accept if it works :) Thanks!

    – Chris B
    May 26 '13 at 17:08











  • Just tried this, got rid of the index line and used location / { try_files index.php index.html/ =404; } Instead of 403 I now get 404. Obviously it is trying the nginx server for index.php, how would I make it try the apache server/make it follow the proxy pass rule?

    – Chris B
    May 26 '13 at 17:22











  • Why did you get rid of the index line? That would certainly cause it to fail.

    – Michael Hampton
    May 26 '13 at 20:59











  • the outcome with or without appears to be the same - it still doesn't try the proxy server for the .php file.

    – Chris B
    May 26 '13 at 21:12











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "2"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f510881%2fnginx-proxy-pass-php-index-problems%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














You need a try_files and a location to put it in.



Example:



location / {
try_files $uri $uri/ =404;
}





share|improve this answer
























  • Not had chance to try yet, when I do I will feedback and accept if it works :) Thanks!

    – Chris B
    May 26 '13 at 17:08











  • Just tried this, got rid of the index line and used location / { try_files index.php index.html/ =404; } Instead of 403 I now get 404. Obviously it is trying the nginx server for index.php, how would I make it try the apache server/make it follow the proxy pass rule?

    – Chris B
    May 26 '13 at 17:22











  • Why did you get rid of the index line? That would certainly cause it to fail.

    – Michael Hampton
    May 26 '13 at 20:59











  • the outcome with or without appears to be the same - it still doesn't try the proxy server for the .php file.

    – Chris B
    May 26 '13 at 21:12
















0














You need a try_files and a location to put it in.



Example:



location / {
try_files $uri $uri/ =404;
}





share|improve this answer
























  • Not had chance to try yet, when I do I will feedback and accept if it works :) Thanks!

    – Chris B
    May 26 '13 at 17:08











  • Just tried this, got rid of the index line and used location / { try_files index.php index.html/ =404; } Instead of 403 I now get 404. Obviously it is trying the nginx server for index.php, how would I make it try the apache server/make it follow the proxy pass rule?

    – Chris B
    May 26 '13 at 17:22











  • Why did you get rid of the index line? That would certainly cause it to fail.

    – Michael Hampton
    May 26 '13 at 20:59











  • the outcome with or without appears to be the same - it still doesn't try the proxy server for the .php file.

    – Chris B
    May 26 '13 at 21:12














0












0








0







You need a try_files and a location to put it in.



Example:



location / {
try_files $uri $uri/ =404;
}





share|improve this answer













You need a try_files and a location to put it in.



Example:



location / {
try_files $uri $uri/ =404;
}






share|improve this answer












share|improve this answer



share|improve this answer










answered May 26 '13 at 0:58









Michael HamptonMichael Hampton

171k27312636




171k27312636













  • Not had chance to try yet, when I do I will feedback and accept if it works :) Thanks!

    – Chris B
    May 26 '13 at 17:08











  • Just tried this, got rid of the index line and used location / { try_files index.php index.html/ =404; } Instead of 403 I now get 404. Obviously it is trying the nginx server for index.php, how would I make it try the apache server/make it follow the proxy pass rule?

    – Chris B
    May 26 '13 at 17:22











  • Why did you get rid of the index line? That would certainly cause it to fail.

    – Michael Hampton
    May 26 '13 at 20:59











  • the outcome with or without appears to be the same - it still doesn't try the proxy server for the .php file.

    – Chris B
    May 26 '13 at 21:12



















  • Not had chance to try yet, when I do I will feedback and accept if it works :) Thanks!

    – Chris B
    May 26 '13 at 17:08











  • Just tried this, got rid of the index line and used location / { try_files index.php index.html/ =404; } Instead of 403 I now get 404. Obviously it is trying the nginx server for index.php, how would I make it try the apache server/make it follow the proxy pass rule?

    – Chris B
    May 26 '13 at 17:22











  • Why did you get rid of the index line? That would certainly cause it to fail.

    – Michael Hampton
    May 26 '13 at 20:59











  • the outcome with or without appears to be the same - it still doesn't try the proxy server for the .php file.

    – Chris B
    May 26 '13 at 21:12

















Not had chance to try yet, when I do I will feedback and accept if it works :) Thanks!

– Chris B
May 26 '13 at 17:08





Not had chance to try yet, when I do I will feedback and accept if it works :) Thanks!

– Chris B
May 26 '13 at 17:08













Just tried this, got rid of the index line and used location / { try_files index.php index.html/ =404; } Instead of 403 I now get 404. Obviously it is trying the nginx server for index.php, how would I make it try the apache server/make it follow the proxy pass rule?

– Chris B
May 26 '13 at 17:22





Just tried this, got rid of the index line and used location / { try_files index.php index.html/ =404; } Instead of 403 I now get 404. Obviously it is trying the nginx server for index.php, how would I make it try the apache server/make it follow the proxy pass rule?

– Chris B
May 26 '13 at 17:22













Why did you get rid of the index line? That would certainly cause it to fail.

– Michael Hampton
May 26 '13 at 20:59





Why did you get rid of the index line? That would certainly cause it to fail.

– Michael Hampton
May 26 '13 at 20:59













the outcome with or without appears to be the same - it still doesn't try the proxy server for the .php file.

– Chris B
May 26 '13 at 21:12





the outcome with or without appears to be the same - it still doesn't try the proxy server for the .php file.

– Chris B
May 26 '13 at 21:12


















draft saved

draft discarded




















































Thanks for contributing an answer to Server Fault!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f510881%2fnginx-proxy-pass-php-index-problems%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

As a Security Precaution, the user account has been locked The Next CEO of Stack OverflowMS...

Список ссавців Італії Природоохоронні статуси | Список |...

Українські прізвища Зміст Історичні відомості |...