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.
Related
I want to block certain IP, and replace the Response with Block Page I made by Flask Server in localhost.
How to config that in Nginx.
For Example:
The program 'A' uses requests.get("http://123.123.123.123/GetInfo")
I want to replace the http://123.123.123.123/GetInfo with HTTP://localhost:5000/GetInfo
Is that possible for Nginx?
I can't change the source code of Program 'A'.
And I don't know what others program in my local will access http://123.123.123.123/GetInfo
I've tried the following configuration:
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name 127.0.0.1;
location /GetInfo {
proxy_pass http://127.0.0.1:6000/GetInfo ;
}
}
server {
listen 123.123.123.123:5000;
server_name 123.123.123.123;
rewrite ^/(.*)$ http://127.0.0.1/$1 permanent;
}
}
It doesn't working.
im trying to start a nginx server on heroku free environmnent. I ready any how-tos and tutorial, but i dont get it running.
First of all, i would like to start nginx as default web-server on Port 80. Afterwards i would like configure nginx as proxy for the underline express server (other heroku instance).
For 4 days i trying to start only nginx on my heroku instance. I always getting the exception that not permitted to start on port 80.
I forked the nginx-buildback (https://github.com/moohkooh/nginx-buildpack) from (https://github.com/benmurden/nginx-pagespeed-buildpack) to adjust some configuration. If i run nginx via heroku bash on port 2555, nginx is starting, but i get connection refused on web-browser.
If i starting nginx via Dyno i getting error message on logs
State changed from starting to crashed
the Procfile of my Dyno
web: bin/start-nginx
My nginx.config.erb
daemon off;
#Heroku dynos have at least 4 cores.
worker_processes <%= ENV['NGINX_WORKERS'] || 4 %>;
events {
use epoll;
accept_mutex on;
worker_connections 1024;
}
http {
gzip on;
gzip_comp_level 2;
gzip_min_length 512;
server_tokens off;
log_format l2met 'measure#nginx.service=$request_time request_id=$http_x_request_id';
access_log logs/nginx/access.log l2met;
error_log logs/nginx/error.log;
include mime.types;
default_type application/octet-stream;
sendfile on;
server {
listen <%= ENV['PORT'] %>;
server_name _;
keepalive_timeout 5;
root /app/www;
index index.html;
location / {
autoindex on;
}
}
}
I also set PORT variable to 80
heroku config:get PORT
80
Some other configuration:
heroku config:get NGINX_WORKERS
8
heroku buildpacks
https://github.com/heroku/heroku-buildpack-multi.git
heroku stack
cedar-14
My .buildpack file
https://github.com/moohkooh/nginx-buildpack
https://codon-buildpacks.s3.amazonaws.com/buildpacks/heroku/ruby.tgz
I also have the guess, that heroku dont use my variable that i set to 80. Whats wrong? Big thanks for anyone.
Btw: my express server running without any error on port 1000 (for test i start it also on port 80 without any errors)
i solved my problem with this configuration.
daemon off;
#Heroku dynos have at least 4 cores.
worker_processes <%= ENV['NGINX_WORKERS'] || 4 %>;
pid nginx.pid;
events {
worker_connections 1024;
}
http {
gzip on;
gzip_comp_level 2;
gzip_min_length 512;
server_tokens off;
log_format l2met 'measure#nginx.service=$request_time request_id=$http_x_request_id';
access_log logs/nginx/access.log l2met;
error_log logs/nginx/error.log;
include mime.types;
server {
listen <%= ENV['PORT'] %>;
server_name localhost;
port_in_redirect off;
keepalive_timeout 5;
root /app/www;
index index.html;
location / {
autoindex on;
}
}
}
For those who are trying to deploy to an NGINX container (React App in my case):
With the help of this docker image I was able to do it. You will need the following in a file called /etc/nginx/conf.d/default.conf.template inside your container:
server {
listen $PORT;
listen [::]:$PORT;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
}
Then in your Dockerfile, use:
CMD /bin/sh -c "envsubst '\$PORT' < /etc/nginx/conf.d/default.conf.template > /etc/nginx/conf.d/default.conf" && nginx -g 'daemon off;'
Now when you run:
> heroku container:push
> heroku container:release
NGINX will use Heroku's assigned PORT to distribute your application
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.
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.
I have a simple nginx setup. When i try to go to the localhost from the browser, i get a 404 error.
Here my nginx config file:
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
ssi on;
location / {
index /srv/http/city_db/static/index.html;
ssi on;
}
}
}
If I simple type in the url-bar in the browser /srv/http/city_db/static/index.html
it instanteneously takes me to the file and all works normally.
And, also I did systemctl restart nginx ofcourse.
Can someone please tell me what I'm doing wrong?
Thanks in advance.
You need to set the root to /srv/http/city_db/static/ and index to index.html. For this configuration you do not need the location block, you can set both at the server level.
server {
listen 80;
server_name localhost;
ssi on;
root /srv/http/city_db/static/;
index index.html;
location / {
# other things you want to set for /
}
}