1

I have setup nginx as my main server, and I'm using that to reverse proxy to apache on port :8080 Here is my nginx config file for apache.example.io

#
# apache.example.io
# Testing apache + nginx
#

server {
        listen 80; 

        root /var/www/apache-example-io; 
        index index.php index.html index.htm;

        server_name apache.example.io www.apache.example.io; 

        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;
            proxy_pass http://127.0.0.1:8080;
        }

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

And here is my file for apache virtualhost

<VirtualHost 127.0.0.1:8080>
    ServerName apache.example.io
    ServerAlias www.apache.example.io
    ErrorLog /var/www/apache-example-io/errror.log
    DocumentRoot /var/www/apache-example-io/public_html
    <Directory "/var/www/apache-example-io/public_html">
       # Order allow,deny
       # Allow from all
       # New directive needed in Apache 2.4.3: 
       # Require all granted
       AllowOverride All
    </Directory>
</VirtualHost>

These work fine if I go to http://apache.example.io/index But I will get a 403 nginx error if I visit http://apache.example.io/ I am not sure how to fix this, error logs for nginx look like the following:

2018/03/14 21:25:24 [error] 24730#0: 6 directory index of "/var/www/" is forbidden, client: 211., server: apache.example.io, request: "GET / HTTP/1.1", host: "apache.example.io"

Googling them and attempting fixes has proved unfruitful :(

  • Who owns /var/www? Who runs nginx? – Gerard H. Pille Mar 15 '18 at 1:45
  • How would I check? I believe earlier did modify permissions for them to be accessed by get and root runs nginx i believe (also not sure how to check this D:) – Cacoon Mar 15 '18 at 1:51
0

So it turns out because I was simply re-routing certain domains I had that all direct towards my server, I hadnt set up a default route.

I opened

/etc/nginx/conf.d/default.conf

And added this in:

server {
  listen 80 default_server; 
  return 404;
}

This will force any non-specified wildcard domains and alike to simply foward to a 404. Where I want to add a new domain, I make a new file for it either with nginx (NodeJS application) and foward to that IP, or make an apache virtualhost for PHP content serving. :)

| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.