Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

proxy_pass not honoring port number?

$
0
0
I want to direct mysite.com/sabnzbd/ to 192.168.0.105:800, which is a daemon with a web interface on another local server. To accomplish this, I want to add a reverse proxy to my nginx.conf. The nginx.conf I am amending is based on the template at https://codex.wordpress.org/Nginx. I added this to the bottom of /global/wordpress.conf

location /sabnzbd/ {
proxy_pass http://192.168.0.105:8000;
proxy_redirect default;
proxy_set_header Host $http_host;
}

but I still get re-redirected to a wordpress 404 site. (Because no port in the address?) Please relate your ideas about whether I added the right code, and if so, what else in this config is negating it?

**********nginx.conf

# Generic startup file.
user nginx nginx;

#usually equal to number of CPUs you have. run command "grep processor /proc/cpuinfo | wc -l" to find it
worker_processes 2;

error_log /www/mysite.com/logs/error.log;
pid /var/run/nginx.pid;

# Keeps the logs free of messages about not being able to bind().
#daemon off;

events {
worker_connections 1024;
}

http {
# rewrite_log on;

include mime.types;
default_type application/octet-stream;
access_log /www/mysite.com/logs/access.log;
sendfile on;
# tcp_nopush on;
keepalive_timeout 3;
# tcp_nodelay on;
# gzip on;
#php max upload limit cannot be larger than this
client_max_body_size 13m;
index index.php index.html index.htm;

# Upstream to abstract backend connection(s) for PHP.
upstream php {
#this should match value of "listen" directive in php-fpm pool
server unix:/var/run/php-fpm/www.sock;
server 127.0.0.1:9000;
}

include sites-enabled/*;
include conf.d/*.conf;
}

**********/sites-available/mysite.conf

# Redirect everything to the main site. We use a separate server statement and NOT an if statement - see http://wiki.nginx.org/IfIsEvil

server {
server_name _;
rewrite ^ $scheme://mysite.com$request_uri redirect;
}

server {
server_name mysite.com;
root /www/mysite.com/public;

index index.php;

include global/restrictions.conf;

# Additional rules go here.

# Only include one of the files below.
include global/wordpress.conf;
# include global/wordpress-ms-subdir.conf;
# include global/wordpress-ms-subdomain.conf;
}


**********/global/wordpress.conf

# WordPress single site rules.
# Designed to be included in any server {} block.

# This order might seem weird - this is attempted to match last if rules below fail.
# http://wiki.nginx.org/HttpCoreModule
location / {
try_files $uri $uri/ /index.php?$args;
}

# Add trailing slash to */wp-admin requests.
rewrite /wp-admin$ $scheme://$host$uri/ permanent;

# Directives to send expires headers and turn off 404 error logging.
location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
access_log off; log_not_found off; expires max;
}

# Uncomment one of the lines below for the appropriate caching plugin (if used).
#include global/wordpress-wp-super-cache.conf;
#include global/wordpress-w3-total-cache.conf;

# Pass all .php files onto a php-fpm/php-fcgi server.
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}

# This is a robust solution for path info security issue and works with "cgi.fix_pathinfo = 1" in /etc/php.ini (default)

include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;
# fastcgi_intercept_errors on;
fastcgi_pass php;
}

location /sabnzbd/ {
proxy_pass http://192.168.0.105:8000;
proxy_redirect default;
proxy_set_header Host $http_host;
}

Viewing all articles
Browse latest Browse all 4759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>