0

I'm using dokku (small heroku) on host with nginx, my container is using apache and it's exposing port 8052.

This is configuration inside of .conf which is enabled and works fine:

LISTEN 8052
<VirtualHost *:8052>
    ServerAdmin veeenex@localhost

    DocumentRoot /var/www
    <Directory />
        Options +FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /var/www/>
        Options +FollowSymLinks +ExecCGI
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>

    FCGIWrapper /phpfarm/inst/php-5.2/bin/php-cgi .php
    AddHandler fcgid-script .php

    LogLevel warn
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

And this is configuration on host

upstream katalog.domain.eu {
  server 172.17.0.3:8052;
}

server {
  listen      [::]:80;
  listen      80;
  server_name katalog.domain.eu;
  access_log  /var/log/nginx/katalog.domain.eu-access.log;
  error_log   /var/log/nginx/katalog.domain.eu-error.log;


  location    / {
    proxy_pass  http://katalog.domain.eu;
    proxy_http_version 1.1;
    proxy_set_header        Host $host;
    proxy_set_header        X-Real-IP $remote_addr;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header        X-Forwarded-Proto $scheme;
    proxy_redirect http://172.17.0.3:8052 https://katalog.domain.eu;

  }

  include /home/dokku/katalog.domain.eu/nginx.conf.d/*.conf;
}

It's working - because I can see the website on http://katalog.domain.eu, but if you click on any form, that makes action (POST,...) url like http://katalog.domain.eu/index changes to http://katalog.domain.eu:8052/index

I've already tried different proxy_set_headers but none of them worked. I don't want to open another port on server, to fix this.

VeeeneX
  • 103
  • 2
  • If it is a redirect causing this, you may need to add more proxy_redirect rules. See [this document](http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_redirect) for details. – Richard Smith Jun 01 '16 at 21:19
  • You appear to be over-using the name `katalog.domain.eu` in the nginx config. Use a simpler name for the `upstream`. – Mike Fiedler Jun 01 '16 at 21:52

1 Answers1

2

You need to check the page where the form is located, and see what is the URL where it makes the POST request in it.

If that is http://katalog.domain.eu:8052, you need to change the application generating that page so that it generates the correct URL.

proxy_redirect changes only the Location and Refresh HTTP headers in the proxied response. It does not change anything in the actual content of the response. This is because the actual content could be anything (HTML, XML, binary data etc.), and running search & replace operations on it is practically impossible.

Tero Kilkanen
  • 34,499
  • 3
  • 38
  • 58