Passing a custom IP address with Nginx proxy server - nginx

My apologies if the title isn't descriptive, I wasn't sure how to word this. I need to connect to a VPN, and need a specific IP address to do it. I was wanting to use Nginx configured as proxy server to do this. Here is my Nginx config file:
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
server {
listen 8080;
server_name name;
location / {
resolver 8.8.8.8;
proxy_pass http://$http_host$uri$is_args$args;
proxy_bind 10.0.0.13;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
I had thought I could achieve what I wanted with proxy_bind, but whenever I try to connect to a website I am given an Nginx error page. I checked the error log, and I get an error saying it couldn't assign the address. I don't even know if that's actually what I want to do. Any suggestions? Thanks in advance.

Related

I get nginx error - location 404 not found

When I try www.abc.com it works but when i try www.abc.com/def or www.abc.com/ghi/ get 404 error.
Here is my nginx config
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name www.abc.com;
location / {
proxy_pass http://I/;
}
location /def{
proxy_pass http://oid-global-windows/;
}
location /ghi/ {
proxy_pass http://oid-global-windows/;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
I tried to tweak the config with alias instead of proxy_pass still no luck. BTW, oid-global-windows is a docker container name and nginx is in another container hosted in same windoes server.
The setup I followed was as per this link -
https://www.mihajakovac.com/run-nginx-webserver-in-docker-on-windows/

Javascript and Css file is not loading while using proxy_pass of Nginx

I have an angular application (say admin app) running at port 4200 in my windows machine. My Nginx is running at port 8080. When request is coming at Nginx I am forwarding it to my angular application (admin app, port 4200) but in that case Js and Css files are not rendered for the admin app and showing 404 error for all css/js files.
My operating System is windows 10
Here is my configuration at nginx.conf file:
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 8080 ;
server_name localhost;
location /admin {
proxy_pass http://localhost:4200/;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
here is the error picture

NGINX web server configuration

I've just downloaded NGINX for Windows and I'm struggeling a bit.
It's up and running with my index file showing at 127.0.0.1:8080, but I'm having problems with connection my web server to my domain.
From what I understand from the documentation I've read online, I had to change the DNS properties at my registrar like this (target-IP is my public IP):
Here is my nginx.conf file:
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 8080;
server_name erikbugge.no www.erikbugge.no;
location / {
root www;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root www;
}
}
}
I have also port-forwarded port 8080 to my local IP address in my router.
The problem now is that whenever I'm trying to access my webpage www.erikbugge.no it simply redirects me to my public IP address.
I'm pretty sure I'm doing something wrong, but I have no idea what it is.
Please be gentle, I'm new to this web server stuff.

nginx proxy - how to allow connection from a specific ip

I've installed nginx and set it up as a forward proxy (see attached nginx.conf)
The server became overloaded and it seems like someone else was using it.
is there a way to limit the nginx proxy to receive request only from specific ips?
Please explain how I should change the nginx.conf to do it for ip 123.456.123.345
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
server {
listen 8080;
location / {
resolver 8.8.8.8;
proxy_pass http://$http_host$uri$is_args$args;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
Do it like this:
location / {
allow 123.456.123.345;
deny all;
resolver 8.8.8.8;
proxy_pass http://$http_host$uri$is_args$args;
}
From the docs:
The rules are checked in sequence until the first match is found.
So if IP equals 123.456.123.345, access will be allowed, otherwise - denied.
If you want to allow multiple IPs, you can specify them before deny all;:
allow 123.456.123.345;
allow 345.123.456.123;
deny all;
"location" directive should be inside a 'server' directive

nginx configuration for rhodecode & redmine on ubuntu 12.04

I am trying to setup rhodecode + redmine on ubuntu with the following
configuration
http://my_ip/redmine
and
http://my_ip/rhodecode
I am using nginx as the web server with redmine running on localhost:3000
and rhodecode running on localhost:5000, somehow iam missing the point in
configuring nginx.conf
I am able to redirect both redmine on port 3000( while testing with webrick) and rhodecode on port 5000 individually but not able to set them as
http://my_ip/redmine
and
http://my_ip/rhodecode
Following is my nginx.conf file
worker_processes 1;
events {
worker_connections 1024;
}
http {
passenger_root /usr/local/rvm/gems/ruby-1.9.3-p374/gems/passenger-3.0.19;
passenger_ruby /usr/local/rvm/wrappers/ruby-1.9.3-p374/ruby;
upstream rhodecode {
server 127.0.0.1:5000;
}
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
root /var/data/redmine/public;
passenger_enabled on;
client_max_body_size 25m; # Max attachemnt size
location /rhodecode/ {
try_files $uri #rhodecode;
proxy_pass http://127.0.0.1:5000;
}
location /rhodecode {
proxy_pass http://127.0.0.1:5000;
}
}
}
It will be easier to make subdomains redmine.yousite.com and rhodecode.yoursite.com. It's also prettier and more agile - you can easily move one of the apps to another server.

Resources