0

i'm trying to use nginx as proxy for my apache all vhosts. i've set up a config file at

/etc/nginx/sites-available/mydomain

and i'also created sym link by using a command

ln -s /etc/nginx/sites-available/mydomain /etc/nginx/sites-enabled/mydomain

the config file is

server {
       listen   80;

        root /home/mydomain/public_html;
        index index.php index.html index.htm;

        server_name mydomain.com www.mydomain.com;

        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:80;
        proxy_pass 192.168.1.104:8080;

         }

         location ~ /\.ht {
                deny all;
        }
}

i also change the Apache to listen 8080 and set the vhost to

then i had restarted the nginx and apache, but finally when i visit http://www.mydomain.com , it displays

Welcome to nginx!

If you see this page, the nginx web server is successfully installed and working. Further configuration is required.

For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.

Thank you for using nginx.

it seems the nginx was not successfully applied the vhosts file. Any ideas?

2
  • Check config with nginx -t. I see, you've missed protocol in proxy_pass.
    – Alexey Ten
    Jul 18, 2014 at 7:04
  • Is that not your virtual host configuration? What is your nginx.conf content? Check if you have 'include /etc/nginx/sites-enabled/*;' in there.
    – Sašo
    Jul 19, 2014 at 20:18

1 Answer 1

0

In the proxy pass you should specify the protocol, hence following should be

location ~ \.php$ {
proxy_set_header X-Real-IP  $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host:80;
proxy_pass http://192.168.1.104:8080;
}

Once changes has been done, restart the nginx server to make the changes effect.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .