I have setup my website with nginx configuration and it is working on this adress : http://178.128.44.106/
Howewer when i try to link a domain name to it, I arrive on a NGINX configuration page : http://lawoodtech.fr/
Here is my nginx configuration :
server {
listen 80;
server_name 178.128.44.106 lawoodtech.fr www.lawoodtech.fr;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/djangoadmin/pyapps/woodtech;
}
location /media/ {
root /home/djangoadmin/pyapps/woodtech;
}
location / {
include proxy_params;
proxy_pass http://unix:/run/gunicorn.sock;
}
}
Any idea on how to fix this ?
Related
Hi I am facing issue when configuring nginx as proxy server to redirect request to my tomcat server. I have 3 tomcat server running on different machine & different port like this
192.168.51.115:8115
192.168.51.120:8120
192.168.51.130:8130
Now I want to config nginx to pass request to my three server sequentially like this
www.example.com/app1
www.example.com/app2
www.example.com/app3
Real IP: 123.123.123.123
This is my configuration under - site-enabled
server {
listen 80;
server_name example.com www.example.com;
location /app1 {
proxy_pass "http://192.168.51.115:8115";
}
location /app2 {
proxy_pass "http://192.168.51.120:8120";
}
location /app3 {
proxy_pass http://192.168.51.130:8130;
}
}
Note: When i put location directive placing just / then it works but doesn't work on /* like app1,app2 or app3
Can you try using ^~ as modifier in your location block ?
like
server {
listen 80;
server_name example.com www.example.com;
location ^~ /app1 {
proxy_pass "http://192.168.51.115:8115";
}
location ^~ /app2 {
proxy_pass "http://192.168.51.120:8120";
}
location ^~ /app3 {
proxy_pass http://192.168.51.130:8130;
}
}
I have Ubuntu, nginx, docker.
After running worpdress docker container everything worked fine.
My wordpress site is runing by docker and has address IP:8050
After adding domain name by used proxy_pass in my nginx config i take ERR_ABORTED 404 (Not Found) in statis file (png, css, js)
This is my nginx config:
server {
listen 80;
listen [::]:80;
server_name domain.com;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
location / {
proxy_pass http://IP:8050/;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}
location ~ /\.ht {
deny all;
}
location = /favicon.ico { log_not_found off; access_log off; }
location = /robots.txt { log_not_found off; access_log off; allow all; }
location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
expires max;
log_not_found off;
}
location ~ ^/css/*(/|$) {
access_log off;
expires max;
}
}
Then I changed url in wp_option in mysql database. Redirect is worked but all statics file is not found. I take error list in my console browser
Example:
GET http://domain/wp-content/plugins/wp-smart-preloader/assets/css/wsp-front-preloader.css?ver=1.11.3 net::ERR_ABORTED 404 (Not Found)
When I comment proxy_pass in nginx config and link to the IP:8050, everything works fine.
Ok, I added only location root [path to worpdress container files]
I am configuring a nginx revser proxy. The result should be when user type http://10.21.169.13/mini, then the request should be proxy_pass to 192.168.1.56:5000. Here is the nginx config:
server {
listen 80;
server_name 10.21.169.13;
location = /mini {
proxy_pass http://192.168.1.65:5000;
include /etc/nginx/proxy_params;
}
}
The above location block never worked with http://10.21.169.13/mini. The only location block worked is:
server {
listen 80;
server_name 10.21.169.13;
location / {
proxy_pass http://192.168.1.65:5000;
include /etc/nginx/proxy_params;
}
}
But the above config also match http://10.21.169.13 request which is too board.
What location block will only match 'http://10.21.169.13/mini` and no more?
UPDATE: tried and failed with the following:
location /mini {
proxy_pass http://192.168.1.65:5000;
include /etc/nginx/proxy_params;
}
location /mini/ {
proxy_pass http://192.168.1.65:5000;
include /etc/nginx/proxy_params;
}
The error is request not found.
Try this out:
server {
listen 80;
server_name 10.21.169.13;
# root /usr/share/nginx/html;
# index index.html index.htm;
location / {
# add something here to handle the root
# try_files $uri $uri/ /index.html;
}
location /mini {
proxy_pass http://192.168.1.65:5000;
include /etc/nginx/proxy_params;
}
}
Let me know if that works for you.
I'm trying to get nginx to point to my index.html page along with imgs, CSS, JS, etc. that lies in a GoPATH, which is outside of /var/www/. My overall objective is to allow my website to run on port 80 and not 8080. Is it possible to do this? Below is what I currently have in the nginx.conf.
user www-data;
http {
include /etc/nginx/proxy.conf;
index index.html
}
server { # simple reverse-proxy
listen 80;
server_name dtrinh.com www.dtrinh.com;
access_log logs/dtrinh.access.log main;
# serve static files
# serve static files
location / {
root /go/src/ps/views/default/index.html;
expires 30d;
# pass requests for dynamic content to rails/turbogears/zope, et al
location / {
proxy_pass http://127.0.0.1:8080;
}
}
location / {
root /go/src/ps/views/default;
error_page 404 = #backend;
expires 30d;
}
location #backend {
proxy_pass http://127.0.0.1:8080;
}
Reference:
http://nginx.org/r/root
http://nginx.org/r/error_page
http://nginx.org/r/location
I have nginx acting as a reverse proxy to apache. I now need to add a new subdomain
that will serve files from another directory, but at the same time I want all location and proxy_pass directives that I have for the default host to apply to the subdomain also.
I know that if I copy the rules from the default host to the new subdomain it will work, but is there a way for the subdomain to inherit the rules?
Below is a sample configuration
server {
listen 80;
server_name www.somesite.com;
access_log logs/access.log;
error_log logs/error.log error;
location /mvc {
proxy_pass http://localhost:8080/mvc;
}
location /assets {
alias /var/www/html/assets;
expires max;
}
... a lot more locations
}
server {
listen 80;
server_name subdomain.somesite.com;
location / {
root /var/www/some_dir;
index index.html index.htm;
}
}
Thanks
You could move the common parts to another configuration file and include from both server contexts. This should work:
server {
listen 80;
server_name server1.example;
...
include /etc/nginx/include.d/your-common-stuff.conf;
}
server {
listen 80;
server_name another-one.example;
...
include /etc/nginx/include.d/your-common-stuff.conf;
}
Edit: Here's an example that's actually copied from my running server. I configure my basic server settings in /etc/nginx/sites-enabled (normal stuff for nginx on Ubuntu/Debian). For example, my main server bunkus.org's configuration file is /etc/nginx/sites-enabled and it looks like this:
server {
listen 80 default_server;
listen [2a01:4f8:120:3105::101:1]:80 default_server;
include /etc/nginx/include.d/all-common;
include /etc/nginx/include.d/bunkus.org-common;
include /etc/nginx/include.d/bunkus.org-80;
}
server {
listen 443 default_server;
listen [2a01:4f8:120:3105::101:1]:443 default_server;
include /etc/nginx/include.d/all-common;
include /etc/nginx/include.d/ssl-common;
include /etc/nginx/include.d/bunkus.org-common;
include /etc/nginx/include.d/bunkus.org-443;
}
As an example here's the /etc/nginx/include.d/all-common file that's included from both server contexts:
index index.html index.htm index.php .dirindex.php;
try_files $uri $uri/ =404;
location ~ /\.ht {
deny all;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location ~ /(README|ChangeLog)$ {
types { }
default_type text/plain;
}