0

I have set a simple reverse proxy setup on my nginx server

user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
    worker_connections 768;
    # multi_accept on;
}

http {

    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush on;
    types_hash_max_size 2048;
    # server_tokens off;

    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    ##
    # SSL Settings
    ##

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
    ssl_prefer_server_ciphers on;

    ##
    # Logging Settings
    ##

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    ##
    # Gzip Settings
    ##

    gzip on;

    # gzip_vary on;
    # gzip_proxied any;
    # gzip_comp_level 6;
    # gzip_buffers 16 8k;
    # gzip_http_version 1.1;
    # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

    ##
    # Virtual Host Configs
    ##

    # include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}

and only file in /etc/nginx/sites-enabled

server {
    
    listen 80 default_server;
    listen [::]:80 default_server;

    index index.html index.htm index.nginx-debian.html;

    location /portainer/ {
        proxy_pass  http://127.0.0.1:9445;
    }
}

on trying to access the server http://192.168.29.118/portainer/ I get 404 page not found response, although I'm able to access http://192.168.29.118:9445 and curl http://127.0.0.1:9445

my access.log looks like this and nothing on my error.log

192.168.29.67 - - [21/Oct/2022:13:20:43 +0000] "GET /portainer/ HTTP/1.1" 404 43 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:106.0) Gecko/20100101 Firefox/106.0"

Have tried looking answers for similar questions but haven't found anything solid to make my config work, appreciate any help!

nginx simple proxy_pass to localhost not working

Bad_Panda
  • 427
  • 1
  • 5
  • 11
  • 2
    Try: `proxy_pass http://127.0.0.1:9445/;` with a trailing `/`. – Richard Smith Oct 21 '22 at 15:28
  • Ah shoot, I thought I have tried all of those possibilities and so happens this solves the issue. Thanks a lot! Is there any way to actually debug stuff like these, cause the logs didn't show what url it was looking after reverse proxy, that would have been very handy in debugging this. – Bad_Panda Oct 21 '22 at 17:28

0 Answers0