Skip to content

Cannot request relative path correctly. #2578

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ghost opened this issue May 29, 2018 · 4 comments
Closed

Cannot request relative path correctly. #2578

ghost opened this issue May 29, 2018 · 4 comments

Comments

@ghost
Copy link

ghost commented May 29, 2018


Is this a BUG REPORT (choose one):

Cannot request resources with relative path on a page.

NGINX Ingress controller version:

0.15.0

Kubernetes version (use kubectl version):

1.10.1

Environment:

  • Cloud provider or hardware configuration: virtual machine
  • OS (e.g. from /etc/os-release): ubuntu 16.04 LTS
  • Kernel (e.g. uname -a): Linux bogon 4.4.0-116-generic proposal: application health check #140-Ubuntu SMP Mon Feb 12 21:23:04 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
  • Install tools: ansible
  • Others:

What happened:

I have a backend service (let's say hello) which is a flask-restplus web service and have the following ingress configuration

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: hello-ingress
  namespace: dev
  annotations:
    nginx.ingress.kubernetes.io/add-base-url: "true"
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  tls:
  - secretName: tls-certificate
    hosts:
    - dev.example.com
  rules:
  - host: dev.example.com
    http:
      paths:
      - path: /hello
        backend:
          serviceName: hello-svc
          servicePort: 8080

when I request http://dev.example.com/hello/ via chrome, it returns a blank page with several 404 errors as follow.

(index):10 GET http://dev.example.com/swaggerui/bower/swagger-ui/dist/css/screen.css net::ERR_ABORTED
(index):6 GET http://dev.example.com/swaggerui/bower/swagger-ui/dist/css/typography.css net::ERR_ABORTED
(index):8 GET http://dev.example.com/swaggerui/bower/swagger-ui/dist/css/reset.css net::ERR_ABORTED
(index):20 GET http://dev.example.com/swaggerui/bower/swagger-ui/dist/lib/handlebars-4.0.5.js net::ERR_ABORTED
(index):15 GET http://dev.example.com/swaggerui/bower/swagger-ui/dist/lib/object-assign-pollyfill.js net::ERR_ABORTED
(index):16 GET http://dev.example.com/swaggerui/bower/swagger-ui/dist/lib/jquery-1.8.0.min.js net::ERR_ABORTED
(index):17 GET http://dev.example.com/swaggerui/bower/swagger-ui/dist/lib/jquery.slideto.min.js net::ERR_ABORTED

obviously, there is no hello in the urls. When I try to request http://dev.example.com/hello/swaggerui/bower/swagger-ui/dist/css/screen.css , it will success.

This is the web page source and <base> tag has been inserted at the top of <head> tag.

<head><base href="http://dev.example.com/hello/">
 <title>Hello</title>
   <link media="screen" rel="stylesheet" type="text/css"
   href="/swaggerui/bower/swagger-ui/dist/css/typography.css" />
   <link media="screen" rel="stylesheet" type="text/css"
   href="/swaggerui/bower/swagger-ui/dist/css/reset.css" />
   <link media="screen" rel="stylesheet" type="text/css"
   href="/swaggerui/bower/swagger-ui/dist/css/screen.css" />
   <link media="print" rel="stylesheet" type="text/css"
   href="/swaggerui/bower/swagger-ui/dist/css/reset.css"/>
   <link media="print" rel="stylesheet" type="text/css"
   href="/swaggerui/bower/swagger-ui/dist/css/screen.css" />
   <script src="/swaggerui/bower/swagger-ui/dist/lib/object-assign-pollyfill.js" type="text/javascript"></script>
   <script src="/swaggerui/bower/swagger-ui/dist/lib/jquery-1.8.0.min.js" type="text/javascript"></script>
   <script src="/swaggerui/bower/swagger-ui/dist/lib/jquery.slideto.min.js" type="text/javascript"></script>
   <script src="/swaggerui/bower/swagger-ui/dist/lib/jquery.wiggle.min.js" type="text/javascript"></script>
   <script src="/swaggerui/bower/swagger-ui/dist/lib/jquery.ba-bbq.min.js" type="text/javascript"></script>
   <script src="/swaggerui/bower/swagger-ui/dist/lib/handlebars-4.0.5.js" type="text/javascript"></script>
   <script src="/swaggerui/bower/swagger-ui/dist/lib/lodash.min.js" type="text/javascript"></script>
   <script src="/swaggerui/bower/swagger-ui/dist/lib/backbone-min.js" type="text/javascript"></script>
    
   <script src="/swaggerui/bower/swagger-ui/dist/swagger-ui.min.js" type="text/javascript"></script>
    
   <script src="/swaggerui/bower/swagger-ui/dist/lib/highlight.9.1.0.pack.js" type="text/javascript"></script>
   <script src="/swaggerui/bower/swagger-ui/dist/lib/highlight.9.1.0.pack_extended.js" type="text/javascript"></script>
   <script src="/swaggerui/bower/swagger-ui/dist/lib/jsoneditor.min.js" type='text/javascript'></script>
   <script src="/swaggerui/bower/swagger-ui/dist/lib/marked.js" type="text/javascript"></script>
    
   <!-- enabling this will enable oauth2 implicit scope support -->
   <script src="/swaggerui/bower/swagger-ui/dist/lib/swagger-oauth.js" type="text/javascript"></script>
    
    
   <script type="text/javascript">
   $(function () {
   // Performance tuning for Highlight.js
   hljs.configure({
   highlightSizeThreshold: 5000
   });
    
    
    
   window.swaggerUi = new SwaggerUi({
   url: "http://dev.example.com/swagger.json",
   validatorUrl: "" \\ null,
   dom_id: "swagger-ui-container",
   supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
   onComplete: function(swaggerApi, swaggerUi){
   if(typeof initOAuth == "function") {
    
   }
    
    
    
   $('pre code').each(function(i, e) {
   hljs.highlightBlock(e)
   });
   },
   onFailure: function(data) {
   log("Unable to Load SwaggerUI");
   },
   jsonEditor: false,
   docExpansion: "none"
   });
   window.swaggerUi.load();
    
   function log() {
   if ('console' in window) {
   console.log.apply(console, arguments);
   }
   }
   });
   </script>
   </head>

I think nginx.ingress.kubernetes.io/add-base-url: "true" works, but still cannot request relative path correctly.

What you expected to happen:

Request relative path correctly.

How to reproduce it (as minimally and precisely as possible):

Always.

Anything else we need to know:

NO

@ghost
Copy link
Author

ghost commented May 29, 2018

According to this post, <base> tag would not work when the href is assigned absolute path.

@aledbf
Copy link
Member

aledbf commented May 29, 2018

Closing. This is working as expected. Your links are absolute, not relative, so the base tag has not effect.

@aledbf aledbf closed this as completed May 29, 2018
@cugblack
Copy link

cugblack commented Jun 3, 2018

@aledbf I got same problem,the base tag has not effect. What should i do to solve it?

@akshit1811
Copy link

@aledbf I have faced the same problem as well, the index.html is going inside the folder defined in the path and the static files in some other directory resulting in 404. Can you please help on this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants