WEIGEL FORUM
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Login

    NGINX basic Reserve Proxy

    Linux
    1
    1
    11
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • DerMeldosD
      DerMeldos
      last edited by

      NGINX and dependencies should already be installed.

      sudo vi /etc/nginx/sites-available/proxy_example.conf
      
      server {
      	listen 80;
      	location /{
      		proxy_pass http://1.1.1.1;
      	}
      }
      

      Proxied:
      example.com/images
      example.com/text
      example.com/video

      Webserver defined under proxy_pass like: proxy_pass http://webserver1.example.com

      Only for /images proxying

      server {
      	listen 80;
      	location /images{
      		proxy_pass http://1.1.1.1;
      	}
      }
      

      Proxied:
      example.com/images/dog.jpg
      example.com/images/animals/cat.jpg

      to log user information for statistical reasons

      server {
      	listen 80;
      	location /{
      		proxy_pass http://1.1.1.1;
      		include proxy_params;
      	}
      }
      

      This includes Instruction specified in another file:

      cat /etc/nginx/proxy_params
      
      proxy_set_header Host $http_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;
      

      Enable "Website" via softlink:

      sudo ln -s /etc/nginx/sites-available/proxy_example.conf /etc/nginx/sites-enabled/proxy.conf
      

      Disbale Default (this is normaly also a softlink so no files will be lost):

      sudo rm /etc/nginx/sites-enabled/default
      

      Check Config files for errors:

      sudo nginx -t
      

      "-t" parameter tells nginx to test config files

      Example Output:

      nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
      nginx: configuration file /etc/nginx/nginx.conf test if successful
      

      proxy.conf will not be shown in the output but will still be tested

      1 Reply Last reply Reply Quote 0
      • First post
        Last post
      Powered by NodeBB | Contributors