Skip to content

Blank page in proxy pass #1544

Closed
Closed

Description

@4nuragk

I have set up reverse proxy in apache for my local code-sever install.

Everything is okay till the login screen, but after that, I get nothing just blank screen. I checked the console log and its full of 200 errors.

Eg. I have set up code-server in local system with IP http://172.x.x.x:8000 and proxy-passed it to https://example.com/abc/test/code-server/

The command I used:
Screenshot (17)

Where am I doing wrong?

Activity

  1. tiborsekera commented on Apr 22, 2020

    @tiborsekera

    then, in your browser, if you go to http://172.18.0.3:8000, don't you get vscode?

  2. 4nuragk commented on Apr 22, 2020

    @4nuragk
    Author

    then, in your browser, if you go to http://172.18.0.3:8000, don't you get vscode?

    Yes, I get vs code when I visit the local ip. But proxy-pass isn't working. I even tried with --auth none flag. I just get a blank page.

    Console log:
    Screenshot (18)

    Proxy pass settings:
    Screenshot (19)

    apache-conf setting(found it somewhere in the issues):

    Screenshot (20)

    I'm under huge pressure of getting this work done. Please help.

  3. changed the title [-]Nothing after login[/-] [+]Blank page in proxy pass[/+] on Apr 22, 2020
  4. code-asher commented on Apr 22, 2020

    @code-asher
    Member

    Do you have the mod_proxy_wstunnel module enabled?

  5. code-asher commented on Apr 22, 2020

    @code-asher
    Member

    Oh you've got a base path. You might just need to include it in the rewrite. Here's a configuration I just tested which seems to work:

    <VirtualHost *:8080>
      ServerName localhost
    
      RewriteEngine On
      RewriteCond %{HTTP:Upgrade} =websocket [NC]
      RewriteRule /test/path/(.*) ws://localhost:8081/$1 [P,L]
      RewriteCond %{HTTP:Upgrade} !=websocket [NC]
      RewriteRule /test/path/(.*) http://localhost:8081/$1 [P,L]
    </VirtualHost>
    
  6. 4nuragk commented on Apr 22, 2020

    @4nuragk
    Author

    I tried that. Not working. I am getting the same error. After debugging I found something.

    debug got message from vs code {"message":{"type":"options","id":"baQ06AJ0CeQaBICxDzAGSvf8","options":{"workbenchWebConfiguration":{"remoteAuthority":"172.16.112.2","logLevel":0},"remoteUserDataUri":{"$mid":1,"path":"/root/.local/share/code-server","scheme":"vscode-remote","authority":"172.16.112.2"},"productConfiguration":{"nameShort":"Code - OSS","nameLong":"Code - OSS","applicationName":"code-oss","dataFolderName":".vscode-oss","win32MutexName":"vscodeoss","licenseName":"MIT","licenseUrl":"https://github.com/Microsoft/vscode/blob/master/LICENSE.txt","win32DirName":"Microsoft Code OSS","win32NameVersion":"Microsoft Code OSS","win32RegValueName":"CodeOSS","win32AppId":"{{E34003BB-9E10-4501-8C11-BE3FAA83F23F}","win32x64AppId":"{{D77B7E06-80BA-4137-BCF4-654B95CCEBC5}","win32UserAppId":"{{C6065F05-9603-4FC4-8101-B9781A25D88E}","win32x64UserAppId":"{{C6065F05-9603-4FC4-8101-B9781A25D88E}","win32AppUserModelId":"Microsoft.CodeOSS","win32ShellNameShort":"C&ode - OSS","darwinBundleIdentifier":"com.visualstudio.code.oss","linuxIconName":"com.visualstudio.code.oss","licenseFileName":"LICENSE.txt","reportIssueUrl":"https://github.com/cdr/code-server/issues/new","urlProtocol":"code-oss","extensionAllowedProposedApi":["ms-vscode.references-view"],"commit":"28e91ba70cd70fa9adf3f2e3e3b87631b5667ecf","date":"2020-04-14T22:51:57.043Z","version":"1.43.2","extensionsGallery":{"serviceUrl":"https://extensions.coder.com/api","itemUrl":"","controlUrl":"","recommendationsUrl":""}},"nlsConfiguration":{"locale":"en","availableLanguages":{}},"commit":"28e91ba70cd70fa9adf3f2e3e3b87631b5667ecf"}}}

    This is the debug log. Here, it is looking for directories(/root/.local/share/code-server) in 172.16.112.2. But that is not the server in which it is installed. That is the main server to which it is proxy-passed.

    How do i make it look into the directory in which it is installed? I guess that might be the error. Also there is some websocket error in console log.

  7. code-asher commented on Apr 22, 2020

    @code-asher
    Member

    The remote authority won't actually affect where it looks for the directory; all files and directories are only accessed on the local machine where code-server is running.

    We always set the remote authority to the host header so that's just what your proxy is providing to code-server. I think the only thing it's used for is setting cookies but it won't be used if it's an IP address so in your case it shouldn't have any effect.

    Were you able to confirm whether you have the mod_proxy_wstunnel module enabled? So far that's the only other way I've been able to replicate the issue.

  8. fresh2dev commented on May 12, 2020

    @fresh2dev

    I also have this issue using a base-path behind a traefik proxy. It worked fine prior to v3.1. The web debugger is full of errors due code-server looking for dependencies at the root path; ignoring the base-path prefix.

  9. code-asher commented on May 12, 2020

    @code-asher
    Member

    For Traefik this might help: #1608 (comment)

  10. joelcox22 commented on May 21, 2020

    @joelcox22

    I had the same issue with nginx when just using the basic proxy_pass option alone. Works with:

    location / {
          proxy_pass http://localhost:8000;
          proxy_http_version 1.1;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection "Upgrade";
          proxy_set_header Host $host;
      }
    
  11. 4nuragk commented on May 21, 2020

    @4nuragk
    Author

    I had the same issue with nginx when just using the basic proxy_pass option alone. Works with:

    location / {
          proxy_pass http://localhost:8000;
          proxy_http_version 1.1;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection "Upgrade";
          proxy_set_header Host $host;
      }
    

    Did you try doing that for a sub directory?

  12. nhooyr commented on May 21, 2020

    @nhooyr
    Contributor

    It's unlikely this is a bug with code-server.

    Can you try to follow our setup guide with caddy and see if you can get it working?

    See https://github.com/cdr/code-server/blob/master/doc/guide.md

    If not I'll reopen.

  13. martiiinthomas commented on Dec 3, 2020

    @martiiinthomas

    I'm having this issue as well with code server using apache. I think this needs to be reopened.

  14. nhooyr commented on Dec 3, 2020

    @nhooyr
    Contributor

    @martiiinthomas It's very likely you don't have apache configured correctly. Please see our configuration guide.

    https://github.com/cdr/code-server/blob/v3.7.4/doc/guide.md

    We recommend caddy for easiest setup but there's also some docs on using nginx.

  15. psuter80 commented on Dec 12, 2020

    @psuter80

    just found this issue because i was struggeling too but i got it to work. here is my apache proxy config:

    Redirect "/ak22vf3/vscode" "/ak22vf3/vscode/"
    <Location "/ak22vf3/vscode/">
        ProxyPass http://172.17.0.3:8080/
        ProxyPassReverse http://172.17.0.3:8080/
        ProxyPassReverse /
        RewriteEngine on 
        RewriteCond %{HTTP:Upgrade} websocket [NC]
        RewriteCond %{HTTP:Connection} upgrade [NC]
        RewriteRule ^/?(.*) "ws://172.17.0.3:8080/" [P,L]
    </Location>
    

    this config needs mod_proxy, mod_proxy_wstunnel, mod_proxy_http and mod_rewrite to be enabled.

    what i did to figure this out: i went to the before mentioned guide.md and basically went through the nginx documentation to decyper what that config does which made me realize, that I was missing the websocket proxy :)

    @nhooyr i would suggest to add the above example to the setup guide. I was bound to apache because i needed some of its html rewrite functionalities for another container i was proxying :)

  16. nhooyr commented on Dec 14, 2020

    @nhooyr
    Contributor

    Thanks @psuter80

    I opened #2452

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions