• Resolved astpaul

    (@astpaul)


    Hi

    I am sure it is a stupid mistake but I am trying to get a wordpress running after installing php-pfm.
    My test info.php file works like a charm and nginx serves it without a problem (see https://wordpress3-635639788058487716.cloudapp.net/info.php) but when requesting my wordpress file (which was working perfectly before the install) it serves me with a 502 Bad Gateway Error.

    Here is my default.conf

    server {
        listen      80 default;
        server_name _;
        root        /var/www/vhosts/default;
        index       index.html index.htm;
        charset     utf-8;
    
        access_log  /var/log/nginx/default.access.log  main;
        error_log   /var/log/nginx/default.error.log;
    
        include     /etc/nginx/drop;
    
        rewrite /wp-admin$ $scheme://$host$uri/ permanent;
        #rewrite ^(.*)(index|home|default)\.html? $1 permanent;
    
        set $mobile '';
        #include /etc/nginx/mobile-detect;
    
         location ~* ^/wp-(content|admin|includes) {
             index   index.php index.html index.htm;
            try_files $uri =404;
            fastcgi_pass unix:/tmp/php5-fpm.sock;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
             if ($request_filename ~ .*\.php) {
    #             break;
    #             proxy_pass https://backend;
             }
             include /etc/nginx/expires;
        }
    
        location ~ \.php$ {
            root           /var/www/vhosts/default;
            try_files $uri =404;
    #        fastcgi_pass   127.0.0.1:9000;
            fastcgi_pass unix:/tmp/php5-fpm.sock;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
    
        #location ~* \.(js|css|html?|xml|gz|jpe?g|gif|png|swf|wmv|flv|ico)$ {
        #    index   index.html index.htm;
        #    include /etc/nginx/expires;
        #}
    
        location / {
            if ($request_filename ~ .*\.php) {
                break;
                proxy_pass https://backend;
            }
            include /etc/nginx/expires;
    
            set $do_not_cache 0;
            if ($http_cookie ~* "comment_author_|wordpress_(?!test_cookie)|wp-postpass_" ) {
                set $do_not_cache 1;
            }
            if ($request_method = POST) {
                set $do_not_cache 1;
            }
            proxy_no_cache     $do_not_cache;
            proxy_cache_bypass $do_not_cache;
    
            proxy_redirect     off;
            proxy_cache        czone;
            proxy_cache_key    "$scheme://$host$request_uri$mobile";
            proxy_cache_valid  200 0m;
            proxy_pass https://backend;
        }
    
        #include     /etc/nginx/phpmyadmin;
        location ~* /(phpmyadmin|myadmin|pma) {
            access_log off;
            log_not_found off;
            return 404;
        }
    
        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/share/nginx/html;
        }
    }

    and my nginx.conf

    user  nginx;
    worker_processes  4;
    
    error_log  /var/log/nginx/error.log warn;
    pid        /var/run/nginx.pid;
    
    events {
        worker_connections  1024;
        use epoll;
    }
    
    http {
        include       /etc/nginx/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"';
        log_format backend '$http_x_forwarded_for - $remote_user [$time_local] "$request" '
                           '$status $body_bytes_sent "$http_referer" '
                           '"$http_user_agent"';
    
        access_log  /var/log/nginx/access.log  main;
    
        server_name_in_redirect off;
        server_tokens      off;
    
        sendfile           on;
        tcp_nopush         off;
    
        keepalive_timeout  5;
    
        client_max_body_size    1200m;
        client_body_buffer_size 256k;
    
        if_modified_since before;
    
        fastcgi_buffer_size 64k;
        fastcgi_buffers 4 64k;
    
        gzip              on;
        gzip_http_version 1.0;
        gzip_vary         on;
        gzip_comp_level   6;
        gzip_types        text/plain
                          text/xml
                          text/css
                          text/javascript
                          application/xhtml+xml
                          application/xml
                          application/rss+xml
                          application/atom_xml
                          application/javascript
                          application/x-javascript
                          application/x-httpd-php;
        gzip_disable      "MSIE [1-6]\.";
    
        proxy_cache_path  /var/cache/nginx/proxy_cache levels=1:2
                          keys_zone=czone:32m max_size=256m inactive=1440m;
        proxy_temp_path   /var/cache/nginx/proxy_temp;
        proxy_cache_key   "$scheme://$host$request_uri";
        proxy_set_header  Host               $host;
        proxy_set_header  X-Real-IP          $remote_addr;
        proxy_set_header  Remote-Addr        $remote_addr;
        proxy_set_header  X-Forwarded-Host   $host;
        proxy_set_header  X-Forwarded-Server $host;
        proxy_set_header  X-Forwarded-For    $proxy_add_x_forwarded_for;
        proxy_set_header  Accept-Encoding    "";
        proxy_hide_header X-Pingback;
        proxy_hide_header Link;
        proxy_hide_header ETag;
        proxy_connect_timeout 5;
        proxy_send_timeout 10;
        proxy_read_timeout 120;
        proxy_cache_use_stale timeout invalid_header http_500 http_502 http_503 http_504;
        proxy_cache_lock on;
        proxy_cache_lock_timeout 5s;
    
        upstream backend {
            server unix:/var/run/nginx-backend.sock;
        }
    
        upstream phpfpm {
            server unix:/var/run/php-fpm.sock;
        }
    
        include /etc/nginx/conf.d/*.conf;
    }

    Thank you so much for your help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter astpaul

    (@astpaul)

    Update:

    I changed and simplified default.conf

    Now /wp-admin pages are served by the server, as well as some inner pages like https://wordpress3-635639788058487716.cloudapp.net/inspirational-pictures/ but not the index page!!!

    Any help please?

    server {
        listen      80 default;
        listen [::]:80 default ipv6only=on;
    
        server_name _;
        root        /var/www/vhosts/default;
        index       index.html index.htm;
        charset     utf-8;
    
        access_log  /var/log/nginx/default.access.log  main;
        error_log   /var/log/nginx/default.error.log;
    
        include     /etc/nginx/drop;
    
        #rewrite /wp-admin$ $scheme://$host$uri/ permanent;
        #rewrite ^(.*)(index|home|default)\.html? $1 permanent;
    
        set $mobile '';
        #include /etc/nginx/mobile-detect;
    
        location / {
            root        /var/www/vhosts/default;
            index  index.php index.html index.htm;
            if (-f $request_filename) {
                expires 30d;
                break;
            }
            if (!-e $request_filename) {
              rewrite ^(.+)$ /index.php?q=$1 last;
            } 
    
            set $do_not_cache 0;
            if ($http_cookie ~* "comment_author_|wordpress_(?!test_cookie)|wp-postpass_" ) {
                set $do_not_cache 1;
            }
            if ($request_method = POST) {
                set $do_not_cache 1;
            }
            proxy_no_cache     $do_not_cache;
            proxy_cache_bypass $do_not_cache;
    
            proxy_redirect     off;
            proxy_cache        czone;
            proxy_cache_key    "$scheme://$host$request_uri$mobile";
            proxy_cache_valid  200 0m;
            proxy_pass https://backend;
        }
    
      location ~ .php$ {
        #fastcgi_pass   localhost:9000;  # port where FastCGI processes were spawned
        fastcgi_pass unix:/tmp/php5-fpm.sock;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;  # same path as above
        fastcgi_param PATH_INFO               $fastcgi_script_name;
        include fastcgi_params;
      } 
    
        #include     /etc/nginx/phpmyadmin;
        location ~* /(phpmyadmin|myadmin|pma) {
            access_log off;
            log_not_found off;
            return 404;
        }
    
        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/share/nginx/html;
        }
    }
    Thread Starter astpaul

    (@astpaul)

    Project cancelled

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Nginx 502 Bad Gateway only when wordpress is requested’ is closed to new replies.