Need to mirror all newly uploaded files from oroginal server to new one.
Direct file upload (HTTP PUT) to new server works fine. When i upload file to original server, file appers only there. Logs on a new server access log:
10.31.181.61 - - [28/Dec/2018:13:08:30 +0300] "PUT / HTTP/1.0" 409 167 "-" "curl/7.47.0" "-"
error log:
2018/12/28 13:08:30 [error] 28983#0: *23 cannot PUT to a collection, client: 10.31.181.61, server: _, request: "PUT / HTTP/1.0", host: "10.31.181.60"
what does this error mean: cannot PUT to a collection
Is it possible to make this setup?
Thanks
Nginx config on original server
location / {
autoindex on;
mirror /mirror;
mirror_request_body on;
}
location /mirror {
proxy_pass http://newserver/;
proxy_pass_request_body on;
}
Config on new server:
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /web;
dav_methods PUT;
location / {
autoindex on;
}
You should also add the filename to the url that you are using with PUT
Related
I follow here to setup separated front-end and back-end in centos 7 (with docker), using nginx to host my front-end, my website works, and all /api/.... requests work, however, when I want to check RESTful API serviced by swagger, got a 404 error, fiddler says:
not found /swagger-ui/index.html
I open 8080 on host and navigate the swagger-ui folder and index.html is just there. and all www folder is given 755 permission.
The nginx site.conf is as below:
server {
listen 80;
index index.html;
server_name localhost;
error_log /var/log/nginx/error.log;
location / {
root /usr/share/nginx/html;
}
location /api {
proxy_pass http://www.example.com:8080/api;
}
location /management {
proxy_pass http://www.example.com:8080/management;
}
location /v2 {
proxy_pass http://www.example.com:8080/v2;
}
location /swagger-ui {
proxy_pass http://www.example.com:8080/swagger-ui;
}
location /swagger-resources {
proxy_pass http://www.example.com:8080/swagger-resources;
}
}
What's wrong?
===============================updated
after issue:
sudo docker logs -f -t --tail 100 docker_nginx_1
found somethings wrong in log file:
2018-07-14T17:35:40.904857522Z 187.67.50.246 - - [14/Jul/2018:17:35:40 +0000] "GET /cgi/common.cgi HTTP/1.1" 404 169 "-" "Wget(linux)" "-"
2018-07-14T17:35:40.904920067Z 2018/07/14 17:35:40 [error] 5#5: *23 open() "/usr/share/nginx/html/cgi/common.cgi" failed (2: No such file or directory), client:187.67.50.246, server: localhost, request: "GET /cgi/common.cgi HTTP/1.1", host: "39.107.246.223"
2018-07-14T17:35:43.896984659Z 187.67.50.246 - - [14/Jul/2018:17:35:43 +0000] "GET /stssys.htm HTTP/1.1" 404 169 "-" "Wget(linux)" "-"
It works after I comment out:
location /swagger-ui {
proxy_pass http://www.example.com:8080/swagger-ui;
}
I thought swagger-ui was served by nginx instead of back-end.
I'm running through an issue setting up Gogs through Nginx on my raspberry.
I just want to be able to redirect http://raspberry-ip-address:3000 to http://raspberry-ip-address/gogs.
Below my nginx virtualhost conf :
server {
listen 80;
server_name localhost;
location /gogs/ {
proxy_pass http://localhost:3000;
}
}
When I go on http:// raspberry-ip-address:3000, I get the installation page from gogs -> so Gogs is runnning well.
When I go on http:// raspberry-ip-address/gogs, I got a 404 Not found error. however the log from Gogs is somehow "reacting" because I get :
[Macaron] 2016-08-24 14:40:30: Started GET /gogs/ for 127.0.0.1
[Macaron] 2016-08-24 14:40:30: Completed /gogs/ 302 Found in 1.795306ms
2016/08/24 14:40:30 [D] Session ID: 8e0bbb6ab5478dde
2016/08/24 14:40:30 [D] CSRF Token: YfL58XxZUDgwim9qBCosC7EXIGM6MTQ3MTk4MDMxMzMxMTQ3MjgzOQ==
For more information here is my nginx/error.log :
request: "GET /localhost HTTP/1.1", host: "192.168.1.15"
2016/08/24 14:40:30 [error] 3191#0: *4 open() "/usr/share/nginx/html/install" failed (2: No such file or directory), client: 192.168.1.12, server: localhost, request: "GET /install HTTP/1.1", host: "192.168.1.15"
It seems to me that Nginx is not redirecting correctly the request. Any idea ?
Thanks ;)
For me the following config works:
location /gogs/ {
proxy_pass http://localhost:3000/;
}
but the following (what you posted) produces the error you mentioned:
location /gogs/ {
proxy_pass http://localhost:3000;
}
note the / and the and of the url.
A HTTP redirect (30x) does not solve the problem, because it will redirect to localhost which is not the raspberry pi but the computer that does the request.
Complete nginx conf in /etc/nginx/nginx.conf:
user nginx;
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 localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
location /git/ {
proxy_pass http://127.0.0.1:3333/;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
}
http{
server {
listen 80;
server_name example.com;
rewrite_log on;
root /etc/nginx/html/mysite;
location ^~ /me/ {
rewrite ^/me/(.*)$ /etc/nginx/html/mysite/$1.html;
}
}
}
The above is not working when I make the request http://example.com/me/all
I want it to be served by /etc/nginx/html/mysite/all.html
But the request goes to /etc/nginx/html/mysite/me/all ignoring the rewrite and nothing about a rewrite error in the logs (just a 404 not found).
You are specifying the root of your virtual host to /etc/nginx/html/mysite (line 6). In your rewrite rule you again specify the whole path /etc/nginx/html/mysite/$1.html (line 8). What nginx does is appending the target of your rewrite rule (/etc/nginx/html/mysite/$1.html) to the root of your virtual host (/etc/nginx/html/mysite). In you example this results in searching for the file:
/etc/nginx/html/mysite/etc/nginx/html/mysite/all.html
Such file does not exist and causes the 404.
Correct the rule to make the target a relative path with respect to root, as:
http{
server {
listen 80;
server_name example.com;
rewrite_log on;
root /etc/nginx/html/mysite;
location ^~ /me/ {
rewrite ^/me/(.*)$ /$1.html;
}
}
}
Remember that you can get more information on these errors by reading the nginx error log (by default placed at /var/log/nginx/error.log). In you case it would have stated something like:
"/usr/share/nginx/html/mysite/usr/share/nginx/html/mysite/all.html" failed (2: No such file or directory), client: 127.0.0.1, server: localhost, request: "GET /me/all HTTP/1.1", host: "localhost"
I have the following config file.
server {
listen 80;
server_name web.example.com;
access_log /var/www/example/shared/log/web.access.log;
error_log /var/www/example/shared/log/web.error.log debug;
rewrite ^/(.*)$ http://www.example.net$request_uri; permanent;
}
When I make a request for curl -Ii -H "Host: example.com" http://example.com the above rewrite rule works. (ARGH)..
The server_name explicitly says "web.example.com"
2014/11/18 22:49:20 [notice] 30694#0: 1868 "^/(.)$" matches "/", client: 1.2.3.4, server: web.example.com, request: "HEAD / HTTP/1.1", host: "example.com"
2014/11/18 22:49:20 [notice] 30694#0: *1868 rewritten redirect: "http://www.example.net/", client: 1.2.3.4, server: web.example.com, request: "HEAD / HTTP/1.1", host: "example.com"
Not present here is the other server { } configs. Xavier (below) pointed out that I had set default_server for listen: 443; but not for listen: 80. (argh)
That's not the strict solution to the issue.
What's happening is that you have only one server block and it becomes the default server block for all requests, even the ones not matching the server name. You simply need to add a default server block in your configuration :
server {
listen 80 default_server;
}
By the way, you have a typo (semicolon before permanent) and you don't need a rewrite as you have specific regular expression. Use this instead :
return 301 http://www.example.net$request_uri;
After a while...
I found that I needed the location / { } wrapped around it
server {
listen 80;
server_name web.example.com;
access_log /var/www/example/shared/log/web.access.log;
error_log /var/www/example/shared/log/web.error.log debug;
location / {
rewrite ^/(.*)$ http://www.example.net$request_uri permanent;
}
}
I testing out nginx but I bumped into a severe problem. Somehow the location tag doesn't catch my uri's. When the browser, or I manually try to access /favicon.ico on my localhost, it just throws an 404 error. The configuration looks like the following code:
server {
listen 80;
server_name localhost;
root www;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
index index.html index.php;
}
location = /favicon.ico {
alias alias /assets/images/favicon.ico;
}
... and the error log looks like this:
2014/01/17 00:05:18 [error] 7408#10036: *82 CreateFile() "C:\Users\user\Webb\nginx/www/favicon.ico" failed (2: FormatMessage() error:(15105)), client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "localhost"
The log proves then that the location block was ignored, because the path nginx look for the file is not the one alias points to.
AFAIK nginx alias goes like this:
alias <the base path>
means that with it you tell the nginx the part to the left of your first "/" in the URI.
example. suppose I have my images in /var/www/html/images and my application refers to apic.jpg as http://app.com/pictures/apic.jpg , what I do then is this:
location ^/pictures {
alias /var/www/html/images;
}
hope this helps.