RHEL7.5 Can't open display via http GET

Posted on

I am trying to execute a bash script via a remote workstation via an apache server.

So I've installed Apache and I can execute test scripts just fine.
But what I'd like to do is to execute a script which is sending a key command (via xdotool) to the current X11 session that is running by the user "vfx".

Script "new.sh":

#!/usr/bin/env sh
export DISPLAY=:"0.0"
export XAUTHORITY=/home/vfx/.Xauthority
xdotool key s

When I try to run it on the remote workstation I always get the following: (from httpd error logs)

[Wed Nov 27 21:30:18.610990 2019] [cgi:error] [pid 2317] [client 192.168.0.194:36750] AH01215: Error: Can't open display: (null)
[Wed Nov 27 21:30:18.611051 2019] [cgi:error] [pid 2317] [client 192.168.0.194:36750] AH01215: Failed creating new xdo instance
[Wed Nov 27 21:30:18.611429 2019] [cgi:error] [pid 2317] [client 192.168.0.194:36750] End of script output before headers: new.sh

I am using Gnome classic.
Connecting via ssh using "export DISPLAY=:"0.0"" and "xdotool key s" is working.

I've already tried the following:
Edit visudo:

apache ALL=(vfx) NOPASSWD: /var/wwww/cgi-bin/new.sh
apache ALL=(vfx) NOPASSWD: /home/vfx/
xhost +

Firewall changes:

# firewall-cmd --zone=public --add-port=6000/tcp   
# firewall-cmd --permanent --zone=public --add-port=6000/tcp 
# firewall-cmd --zone=public --add-port=177/udp 

Edited: /etc/gdm/custom.conf:

# GDM configuration storage
[daemon]
[security]
DisallowTCP=false
[xdmcp]
ServerArguments=-listen tcp
Enable=true
[chooser]
[debug]
# Uncomment the line below to turn on debugging
#Enable=true

Edited: /etc/ssh/sshd_config

x11 forwarding yes

I've researched about this around 15 hours in the last couple of days, so any help would be greatly appreciated.