When we enable the RabbitMQ Web Management Console then it is accessible by http://ip:15672.
Instead of this i want to access RabbitMQ managment console by this http://ip/rabitmq by using nginx
I have done changes in the nginx.
server {
listen 80;
server_name _;
location /rabbitmq {
proxy_pass http://localhost:15672;
}
}
but i dont know how to configure path prefix in rabbitnq ?
I suggest you read:
https://github.com/docker-library/rabbitmq/issues/249
In short, you can configure this in the /etc/rabbitmq/rabbitmq.conf by adding the following line:
management.path_prefix = /rabbitmq
If you are running in a docker environment, you will need to modify:
location /rabbitmq {
proxy_pass http://localhost:15672;
}
to
location /rabbitmq {
proxy_pass http://CONTAINERS_HOSTNAME:15672;
}
Related
I have a situation where we have multiple test environments. Each environment needs to access different versions of a service and we have an NGINX proxy that sits in-front of these different services. Currently we're using multiple servers to do the proxy. Is there a way I can use NGINX allow or deny to filter which backend the environments connect to based on remote IP?
The v1 environment has IP addresses in the 10.0.1.0/24 range, and v2 is only connected to by IP's in 10.0.2.0/24.
Current Config
Simplified for brevity.
server {
listen 80;
server_name service.v1.net;
proxy_pass http://10.0.10.56:8081;
}
server {
listen 80;
server_name service.v2.net;
proxy_pass http://10.0.10.56:8082;
}
What I've tried
Clearly this doesn't work.
server {
listen 80;
server_name service.net;
location / {
# v1 proxy
allow 10.0.1.0/24;
deny all;
proxy_pass http://10.0.10.56:8081;
}
location / {
# v2 proxy
allow 10.0.2.0/24;
deny all;
proxy_pass http://10.0.10.56:8082;
}
}
Also Note...
I know this can be done with serving a proxy on different ports and iptables rules - I'm trying to figure out if NGINX can do this by itself.
You can use ngx_http_geo_module for that. (Which should just work out of the box). It sets variables depending on the client IP address, which can then be used in an if.
geo $environment {
10.0.1.0/24 v1;
10.0.2.0/24 v2;
}
server {
listen 80;
server_name service.net;
location / {
if ($environment = v1) {
proxy_pass http://10.0.10.56:8081;
}
if ($environment = v2) {
proxy_pass http://10.0.10.56:8082;
}
}
}
All other IPs will see a 404 in this case.
Although this works, be advised that using if within a location block can be very tricky: http://wiki.nginx.org/IfIsEvil
I'm trying to configure Nginx location for hours, not sure what I'm doing wrong:
server {
listen 80;
server_name test.myserver.com;
location = / {
root /www/;
}
location / {
proxy_pass http://192.168.0.170;
}
}
Nginx is running on OpenWRT router, inside /www/ there is only a index.html file. All other addresses should be proxied to an Arduino in 192.168.0.170.
I understand "location = /" rule should precede "location /". I'm avoiding creating a rule for any other address than "/", like /a, /b, /c, and go on.
With this code, I get a 404 from "/", as there is no index.html in 192.168.0.170. If I remove "location / { proxy_pass ...}", I could get index.html result from "/" address.
EDIT:
-Including a return 302 /blah; inside "location = /" block works fine, so the rule is being applied.
For anyone that drop here, the solution I've found:
server {
listen 80;
server_name test.myserver.com;
root /www/;
location = / { }
location /index.html { }
location / {
proxy_pass http://192.168.0.170;
}
}
Ugly, but it works. Maybe OpenWRT implementation (version 1.12.2) isn't as reliable a full distribution (current in 1.19.1 version).
In my example, just copied you configuration and did a little tweak, to match with a current configuration I use in my server.
Changed the listen to a default_server
Added root to the server block.
Added index index.html index.htm; line.
You can try the following configuration:
server {
listen 80 default_server;
root /www;
index index.html index.htm;
server_name test.myserver.com;
location / {
proxy_pass http://192.168.0.170;
}
}
After change your configuration test your server block file with command:
sudo nginx -t
If everything is okay, restart the nginx instance:
sudo nginx -s reload
After restart with success if you are trying access via browser, try using incognito mode in a new browser instance. (just for cache clean)
I'm a bit new to using nginx so I'm likely missing something obvious. I'm trying to create an nginx server that will reverse proxy to a set of web servers that use https.
I've been able to get it to work with one server list this:
server {
listen $PORT;
server_name <nginx server>.herokuapp.com;
location / {
proxy_pass https://<server1>.herokuapp.com;
}
}
However, as soon I try to add in the 'upstream' configuration element it no longer works.
upstream backend {
server <server1>.herokuapp.com;
}
server {
listen $PORT;
server_name <nginx server>.herokuapp.com;
location / {
proxy_pass https://backend;
}
}
I've tried adding in 443, but that also fails.
upstream backend {
server <server1>.herokuapp.com:443;
}
server {
listen $PORT;
server_name <nginx server>.herokuapp.com;
location / {
proxy_pass https://backend;
}
}
Any ideas what I'm doing wrong here?
I want to configure nginx to be a reverse proxy using upstream directive (and add there keepalive for example).
upstream my_backend {
server 127.0.0.1:3579;
}
server {
listen 80;
location / {
proxy_pass http://my_backend;
}
}
But the problem is that it returns Bad Request (Invalid host). And there is nothing in nginx error log to help me solve it.
Everything else being the same this configuration without upstream directive works as expected:
server {
listen 80;
location / {
proxy_pass http://127.0.0.1:3579;
}
}
Aren't those two equivalent? And what do I have to do to make it work with upstream?
I have one dedicated server in that server I deployed 5 nodejs application.
domain name: www.nnd.com
dedicated server ip: xxx.xx.x.60
I had domain which is pointed to my dedicated server ip.
sub domains are :
app1.nnd.com pointed to xxx.xx.x.60
app2.nnd.com pointed to xxx.xx.x.60
app3.nnd.com pointed to xxx.xx.x.60
app4.nnd.com pointed to xxx.xx.x.60
app5.nnd.com pointed to xxx.xx.x.60
now in nginx configuration file based on the subdomain I need to route proxy.
Example:
{
listen:80;
server_name:xxx.xx.x.60
location / {
#here based on subdomain of the request I need to create proxy_pass for my node application
}
}
Is there any condition and how can I get the original domain name from proxy header?
create a virtual host for each
server {
server_name sub1.example.com;
location / {
proxy_pass http://127.0.0.1:xxxx;
}
}
server {
server_name sub2.example.com;
location / {
proxy_pass http://127.0.0.1:xxxx;
}
}
And go on, change the port number to match the right port.
You can use RegExp to fetch host name like this
server {
server_name ~^(www\.)?(?<domain>.+)$;
location / {
root /sites/$domain;
}
}
You can create virtual host for every sub domain.
For Ex you have 2 sub domain abc.xyz.com and abcd.xyz.com , and you want to host it on nginx single instance by proxy_pass then you can simply create virtual host for every sub domain
server {
server_name abc.xyz.com;
location / {
proxy_pass http://127.0.0.1:8000;
}
}
server {
server_name abcd.xyz.com;
location / {
proxy_pass http://127.0.0.1:8000;
}
}
For more information you can refer here