0

after trying three times in other StackExchange Forums, I hope I'm getting an answer here.

I switched my wordpress webserver from apache2 to nginx (please note that I want to use the existing wordpress instance) and now I just can't connect to it. Sometimes I get connection refused and if that's not the case I get 403: Forbidden.

What is the best solution to fix that problem? My nginx.conf:

user  www-data;
worker_processes  auto;

pid /run/nginx.pid;

events {
    worker_connections  1024;
}

http {

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

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';
    error_log  /var/log/nginx_error.log error;
    access_log  /var/log/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    # SSL
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # no sslv3 (poodle etc.)
    ssl_prefer_server_ciphers on;

    # Gzip Settings
    gzip on;
    gzip_disable "msie6";
    gzip_vary on;
    gzip_min_length 512;
    gzip_types text/plain application/x-javascript text/javascript application/$

    fastcgi_cache_path /usr/share/nginx/cache/fcgi levels=1:2 keys_zone=microca$


    include /etc/nginx/sites-enabled/*.conf;
}

My wordpress.conf:

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /var/www/html;
    index index.php index.html index.htm;

    server_name snapecraft.ddns.net;
    access_log            /var/log/nginx/vhost1.access.log;
   error_log             /var/log/nginx/vhost1.error.log;
    location / {
        try_files $uri /index.php?$args;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }

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

Thanks for your help!

  • 1
    Can you also share your relevant old Apache configuration? – Tommiie Oct 16 '18 at 12:39
  • 1
    Please find and provide lines with "403 error" from your nginx access/error logs. – Alexander Makarenko Oct 16 '18 at 13:01
  • 1
    What's in the error log? – Michael Hampton Oct 16 '18 at 13:25
  • Somehow the error log is empty/there are only old, already fixed errors in there. Are my log settings OK? – Marius S Oct 16 '18 at 15:33
0

If you're simply trying to list directory contents use autoindex on; like:

location /somedir {
       autoindex on;
}

sudo nginx -s reload

  • Not that what I want to do, but I'll give it a try. Is it possible to set the dir to the root? – Marius S Oct 16 '18 at 15:25

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.