/swagger-ui/index.html not found - nginx

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.

Related

How to resolve the error in NGINX log - PUT with range is unsupported

I set up my NGINX server with WebDAV for file upload. Some files are uploading without an issue, but some fail with a 501 error. Here is the NGINX config
server {
listen 443 ssl;
server_name real_server_name_here;
root /var/www/webserver/public;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
ssl_certificate /etc/nginx/ssl/fullchain.pem;
ssl_certificate_key /etc/nginx/ssl/private/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!ADH:!MD5:!aNULL;
#ssl_dhparam
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
index index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location /app/provision/logs {
limit_except PUT GET {
deny all;
}
dav_methods PUT;
dav_access group:rw all:r;
client_max_body_size 10M;
}
}
This is what I see in the access log when the upload fails:
23.242.x.x - - [08/Oct/2022:10:11:21 -0700] "PUT /app/provision/logs/4825670xxxx-app.log HTTP/1.1" 501 165 "-" "FileTransport PolycomVVX-VVX_250-UA/6.3.1.11465 (SN:4825670xxxx) Type/Application"
23.242.x.x - - [08/Oct/2022:10:11:21 -0700] "PUT /app/provision/logs/4825670xxxx-app.log HTTP/1.1" 501 165 "-" "FileTransport PolycomVVX-VVX_250-UA/6.3.1.11465 (SN:4825670xxxx) Type/Application"
47.153.x.x - - [08/Oct/2022:10:11:23 -0700] "PUT /app/provision/logs/64167f5xxxx-app.log HTTP/1.1" 501 165 "-" "FileTransport PolycomVVX-VVX_411-UA/6.3.1.11465 (SN:64167f5xxxx) Type/Application"
47.153.x.x - - [08/Oct/2022:10:11:23 -0700] "PUT /app/provision/logs/64167f5xxxx-app.log HTTP/1.1" 501 165 "-" "FileTransport PolycomVVX-VVX_411-UA/6.3.1.11465 (SN:64167f5xxxx) Type/Application"
And here is the error log showing the error. I tried to research it and didn't find any solutions.
2022/10/08 10:11:41 [error] 1553835#1553835: *11114 PUT with range is unsupported, client: 23.242.x.x, server: real_server_name_here, request: "PUT /app/provision/logs/4825670xxxx-app.log HTTP/1.1", host: "real_hostname_here"
2022/10/08 10:11:41 [error] 1553835#1553835: *11114 PUT with range is unsupported, client: 23.242.x.x, server: real_server_name_here, request: "PUT /app/provision/logs/4825670xxxx-app.log HTTP/1.1", host: "real_hostname_here"
2022/10/08 10:11:43 [error] 1553835#1553835: *11115 PUT with range is unsupported, client: 47.153.x.x, server: real_server_name_here, request: "PUT /app/provision/logs/64167f5xxxx-app.log HTTP/1.1", host: "real_hostname_here"
2022/10/08 10:11:43 [error] 1553835#1553835: *11115 PUT with range is unsupported, client: 47.153.x.x, server: real_server_name_here, request: "PUT /app/provision/logs/64167f5xxxx-app.log HTTP/1.1", host: "real_hostname_here"
Worth mentioning that if the file doesn't exist it uploads just fine. But when the file needs to be overwritten, it fails. I have other folders on the server that accept files and don't fail. They are set up identically. I checked all permissions on the server, and the web server has all the required rights to upload files.
Any help pointing in the direction of solving this issue is greatly appreciated.

HLS streaming, nginx reverse proxy, proxy_pass with variable

I trying to reverse proxy a HLS stream (m3u8).
My nginx config :
server {
server_name proxy.domain.com;
resolver 8.8.8.8;
location / {
set $backend $arg_url;
proxy_pass http://$backend;
}
}
When I try to access the stream with http://proxy.domain.com/hls/live/stream.m3u8?url=stream.domain.com
It gives me HTTP/1.1" 200 for the m3u8
"GET /hls/live/stream.m3u8?url=stream.domain.com HTTP/1.1" 200
But after it, it gives HTTP/1.1" 500 error for the .ts file !
"GET /hls/live/20190502T232455-05-14196689.ts HTTP/1.1" 500
When I check the error log file
[error] 32069#32069: *16 invalid URL prefix in "http://", client: MY IP, server: proxy.domain.com, request: "GET /hls/live/20190502T232455-05-14196689.ts HTTP/1.1", host: "proxy.domain.com", referrer: "http://player.url.com/?source=https://proxy.domain/hls/live/stream.m3u8?url=stream.domain.com"
I've tried proxy_pass http://$arg_url; but it's not working too.
Can someone help ?

NGINX mirror files uploaded with HTTP PUT

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

[Nginx][Gogs] Serving gogs through nginx

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;
}
}
}

xml sitemap forbidden for access via nginx

My nginx site configuraton:
upstream nodeName {
server serverIp:7050;
server serverIp:7049 backup;
}
server {
listen 80;
server_name domain.com;
gzip_types application/x-javascript text/css;
access_log /pathToLogs/log.access.log;
location / {
proxy_pass http://nodeName/;
}
location ~ ^/(min/|images/|bootstrap/|ckeditor/|img/|javascripts/|apple-touch-icon-ipad.png|apple-touch-icon-ipad3.png|apple-touch-icon-iphone.png|apple-touch-icon-iphone4.png|generated/|js/|css/|stylesheets/|robots.txt|humans.txt|favicon.ico|xml/) {
root /pathToSite/appdirectory-build;
access_log off;
expires max;
}
}
I want to get sitemap.xml by url http://example.com/xml/sitemap.xml but it gives me
403 Forbidden
nginx/1.4.6 (Ubuntu)
Update
In nginx error log file:
2014/10/09 [error] 16094#0: *49762240 open() "/pathToSite/appdirectory-build/xml/sitemapCallEn.xml" failed (13: Permission denied), client: Ip, server: domain.com, request: "GET /xml/sitemapCallEn.txt HTTP/1.1", host: "domain"
How to change permission and allow to open xml file?
Look into nginx error log. You will find answer there. It's file permission issue likely

Resources