Hello Team,
I am trying to configure Nginx to act as reverse proxy to one of my web server. For the purpose of testing I am using "https://google.com" as my backend service. When I launch the Nginx server and navigate to the desired path 'http://localhost:8008/console' (this is the configuration in my nginx.conf file) I am not able to see the Google home page, instead I am seeing a 404 from google. This is happening because when Nginx is trying to call the backend 'https://google.com' service it is appending the requested location from nginx.conf fle to the backend service url, that means instead of sending a request to 'https://google.com' nginx is sending request to 'https://google.com/console'. Below is the content from my nginx.conf file. Kindly help in fixing my issue.
********************************************************
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
# Logging settings
access_log logs/access.log;
error_log logs/error.log;
# Enable Gzip compression
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
# Server block
server {
listen 8008;
server_name localhost; # Replace with your domain
# Location block to handle all requests
location /console {
# Reverse proxy configuration
proxy_pass https://www.google.com; # Replace with your backend server address
}
# Additional location blocks can be defined as needed
# Example: location /images/ { ... }
}
}
******************************************************