I'm trying to test my reverse proxy using php, so my steps were:

1- changed the apache config to make Listen 2- made a nginx config file in conf.d/default.conf and here is my configuration:

    server {
        listen   80;

        root /usr/share/nginx/html/;
        index index.php index.html index.htm;

        server_name _;

        location / {
        try_files $uri $uri/ /index.php;

        location ~ \.php$ {

        proxy_set_header X-Real-IP  $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $host;


         location ~ /\.ht {
                deny all;

4- then I changed the user in nginx.confto be apache and root to be /var/www/html/ so it would be something like this:

user apache;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    include /etc/nginx/conf.d/*.conf;

    server {
        listen       80 default;
        #listen       [::]:80 default_server;
        server_name  #public_IP_addr;
        root         /var/www/html;

        #Load configuration files for the default server block.
    #include /etc/nginx/default.d/*.conf;
        error_page 500 502 503 504 /50x.html;
            location = /50x.html {

5- then I created a two files in /var/www/html/, the first called index.html and the second is called index.php

6- restarted my services and no issues and nginx -t reports no problems

7- went on my ip addr and it shows the index.html no problem at all but when I go to myipaddr/html.php the following output in plain text shows:

<?php phpinfo(); ?>

instead of the actual phpinfo code to make sure that it's handled by the apache handler.

I would like to have it be loaded as a php file on the URL specified/html.php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.