0

I have a nginx reverse proxy setup for apache wordpress which works fine. However based on location need to redirect to an external url which fails. Please check the below config. Is this a valid setup ?

Any help ?

server {
    listen 443 ssl default_server;
    listen [::]:443 default_server;

    server_name platform.com;
    server_tokens off;

    root /var/www/html/def/public/;
    index index.php;

    ssl on;
    ssl_certificate /tmp/fgh.crt;
    ssl_certificate_key /tmp/fgh.pem;

    access_log /var/log/nginx/access2.log;
    error_log /var/log/nginx/error2.log;

    location / {
            proxy_set_header X-Forwarded-Proto $scheme;
            try_files $uri @apache;
    }

    location @apache {
            proxy_set_header X-Real-IP  $remote_addr;
            proxy_set_header X-Forwarded-For $remote_addr;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header Host $host;
            proxy_pass http://127.0.0.1:8080;
    }

     location ~[^?]*/$ {
            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 /pen {
            proxy_pass https://abcdef.com;
    }
   }
  • If you want to redirect not proxy then you need return not proxy_pass in the /pen location – Drifter104 Sep 20 '18 at 15:53
0

After changing the server name (wordpress site) from http prefix to www prefix, proxy pass re directions worked. Had to redirect all http https server blocks to www server block in nginx config

| 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.