Maltanis
Maltanis

Reputation: 523

Apache NiFi - The request contained an invalid host header

I'm running an Apache NiFi instance using Docker at my workplace with a proxy in place. I pulled the official container down, spun up the container and set it to port over to 8081 instead of 8080 as the work proxy is set for 8080.

However when I try to access NiFi via the browser on my dev machine using http://localhost:8081/nifi I'm getting the following error appear

System Error

The request contained an invalid host header [localhost:8081] in the request [/nifi]. Check for request manipulation or third-party intercept.

I've found a couple of posts online mention the nifi.properties file, but I'm not very experienced with Docker outside of spinning up images.

If anyone can offer some guidance or a soltion that would be excellent. Many Thanks.

Upvotes: 6

Views: 17160

Answers (4)

JD Nayak
JD Nayak

Reputation: 41

I was also struggling with the same issue. Below is my docker compose file

--- version: "3" services:   nifi:
    image: apache/nifi
    container_name: nifi
    volumes:
      - /home/user/nifi/conf:/opt/nifi/conf
    ports:
      - 8443:8443
    environment:
      - NIFI_WEB_HTTPS_PORT:8443
      - NIFI_WBE_HTTP_HOST=xx.xx.xx.xx
      - NIFI_WEB_PROXY_HOST=xx.xx.xx.xx:8443
      - SINGLE_USER_CREDENTIALS_USERNAME:admin
      - SINGLE_USER_CREDENTIALS_PASSWORD:ctsBtRBKHRAx69asEqUghvvgnaLjFEB
    restart: always

What helped was adding the below line

  - NIFI_WEB_PROXY_HOST=xx.xx.xx.xx:8443

I can access via my ip:8443 but the Username and Password are not working as of now.

Upvotes: 2

omkar more
omkar more

Reputation: 175

I am using docker apache/nifi image which is having nifi_version : 1.14 After adding env variable NIFI_WEB_PROXY_HOST it worked without error

docker container  run --name nifi -p 8443:8443   -d -e NIFI_WEB_HTTPS_PORT=8443 -e NIFI_WEB_PROXY_HOST='192.168.100.100:8443'  apache/nifi:latest

Upvotes: -1

Shiny
Shiny

Reputation: 593

In my case I just specified the nifi.web.http.host property to the host IP and it works correctly.

File nifi.properties:

# web properties #
nifi.web.war.directory=./lib
nifi.web.http.host=192.168.0.69
nifi.web.http.port=8080

More info about that, I use the binary packages directly in my host. I think the hostname is not match the IP so nifi reported System Error.

For docker usage I'll find more later.

Upvotes: 1

Andy
Andy

Reputation: 14184

If you don't want to modify the nifi.properties file directly, you can pass custom variables to the application during the Docker command using the -e flag. In your case, Docker is aware that port 8081 should map to 8080, but NiFi is not, and detects a mismatch on the incoming request host header. To pass this through, try using a command like the following.

docker run --name nifi \
-p 8081:8081 \
-d \
-e NIFI_WEB_HTTP_PORT='8081'
apache/nifi:latest

Upvotes: 9

Related Questions