Linux Nginx reverse proxy task marked as failed and now expired

Hello @Inderpreet @player001 ,

I already posted here to check the task as it was getting failed.

Here is a new request to check my task as it was getting failed !!!

I was successfully able to curl from jump host.

Here is my solution

- hosts: backupserver
  become: true
  tasks:
    - name: Install yum packages
      yum:
        name: epel-release
        state: latest

    - name: Install Apache(httpd)
      yum:
        name: httpd
        state: latest
    - name: Install Nginx
      yum:
        name: nginx
        state: latest
      notify:
      - Restart services

    - name: Configure httpd.conf port
      lineinfile:
        path: /etc/httpd/conf/httpd.conf
        regexp: '^Listen '
        insertafter: '^#Listen '
        line: Listen 8086

    - name: Copy Nginx conf -> default.conf to backup server
      copy:
        src: default.conf
        dest: /etc/nginx/conf.d/

    - name: Copy index.html to backup server
      copy:
        src: /home/index.html
        dest: "{{ item }}"
      with_items:
        - /var/www/html/
        - /usr/share/nginx/html/
        
    - name: Start Services
      systemd: 
        name: "{{ item }}"
        state: started
        enabled: yes
      with_items :
        - httpd
        - nginx

  handlers:
    - name: Restart services
      systemd:
        name: "{{ item }}"
        state: restarted
      with_items:
        - httpd
        - nginx 
  • default.conf
server {
        listen   8093; 

        root /usr/share/nginx/html/; 
        index index.php index.html index.htm;

        server_name _; 

        location / {
        try_files $uri $uri/ /index.php;
        }

        location ~ \.php$ {
        
        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 ~ /\.ht {
                deny all;
        }
}
  • 2nd time I got another type of error -

PS: I properly configured ports in my configuration file. Below is the screenshot to check that I was able to curl from jump host.

The task is marked now as Expired !!!

Please let me know !!!

Thanks

Can I get any response please from the KodeKloud team !!! @Inderpreet @player001 @mmumshad @vijin.palazhi !!!

@royki you were supposed to copy the sample index file in Apache’s document root rather than in Nginx document root so that Nginx can server that from Apache’s document root, in short that’s how reverse proxy should work.

Well I did that initially - copied index.html file only to /var/www/html/ dir. It was giving same error. Later I added the nginx path if that works. But nothing was giving Success.