How to configure a redirect from the domain name/IP address to the server hostname on port 8443 in Plesk for Linux?

Follow

Comments

12 comments

  • Avatar
    Bernhard

    Hi Nikita,

    thx for that tutorial. It works for me, but now I have the problem that the Plesk Migrator throws this error:

    Failed to check Plesk API connection to target Plesk server: HTTP request to 'https://1.2.3.4:8443/enterprise/control/agent.php' failed with 301 code. When I empty the z-plesk.inc file everything works as expected.

    I've tried different solutions like that, but all didn't work (and it's the first time I'm working with nginx config files:

    set $redir 1;
    if ($host ~ 'example.com'){ set $redir 0; }
    if ($host ~ '1.2.3.4'){ set $redir 0; }
    if ($redir = 1){ rewrite ^/(.*)$ https://example.com:8443/$1 permanent; }

    Thanks for your help.

    0
    Comment actions Permalink
  • Avatar
    Ivan Postnikov

    Hello @Bernhard,

    A deeper investigation is required.

    Please, consider submitting a request for Plesk support.

    0
    Comment actions Permalink
  • Avatar
    Greg Sevatos

    The redirect from a domain name to hostname solution at the bottom of the article conflicts with the Advanced Monitoring extension in Plesk. Soon as i removed the above redirect, Advanced Monitoring started working again.

    0
    Comment actions Permalink
  • Avatar
    amarjeet (Edited )

    Follwed all the steps but when i have restarted server i got error.

    [root@server conf.d]# service sw-cp-server restart && service sw-engine restart
    Restarting sw-cp-server (via systemctl): Job for sw-cp-server.service failed because the control process exited with error code. See "systemctl status sw-cp-server.service" and "journalctl -xe" for details.
    [FAILED]

    [root@server ~]# systemctl status sw-cp-server.service
    ● sw-cp-server.service - Startup script for Plesk control panel server
    Loaded: loaded (/usr/lib/systemd/system/sw-cp-server.service; enabled; vendor preset: disabled)
    Drop-In: /usr/lib/systemd/system/sw-cp-server.service.d
    └─respawn.conf
    Active: activating (auto-restart) (Result: exit-code) since Sun 2020-04-26 14:49:39 EEST; 4s ago
    Process: 8734 ExecStartPre=/usr/sbin/sw-cp-serverd -q -t (code=exited, status=1/FAILURE)

    Apr 26 14:49:39  systemd[1]: Failed to start Startup script for Plesk control panel server.
    Apr 26 14:49:39  systemd[1]: Unit sw-cp-server.service entered failed state.
    Apr 26 14:49:39  systemd[1]: sw-cp-server.service failed.

     

    any clue?

    0
    Comment actions Permalink
  • Hi amarjeet,

    What steps did you follow? What Plesk version you use? And what is what you want to do exactly? What kind of redirect?

    0
    Comment actions Permalink
  • Avatar
    eamon

    Hi Amin team

    execute

    plesk bin admin --enable-access-domain ''

    did not work , !!!!!!!!!!!!!!!!!!

    please advise

     

    0
    Comment actions Permalink
  • Avatar
    Ivan Postnikov

    Hello eamon

    What was the output of this command?

    Was it different from below example?

    SUCCESS: Plesk is now accessible over the TCP port 443 (HTTPS) using the domain: default.

     

    0
    Comment actions Permalink
  • Avatar
    Milos Bajcetic

    I used this method to redirect all panel requests to server hostname, but starting from month ago my Advanced Monitoring not working, when this method is implemented.

    Error Advanced monitoring throw is:  login.OAuthLogin(NewTransportWithCode)

    When rules are removed from  this file /etc/sw-cp-server/conf.d/z-plesk.inc, Advanced Monitoring Tool start working again.

    I re-installed latest Grafana and Advanced Monitoring Extensions, with updates

    1.4.3 (19 June 2021) - Advanced Monitoring Extension

    1.2.3 (18 June 2021) - Grafana Extension

    Logs:

    tail /var/log/grafana/grafana.log
    t=2021-06-19T14:45:57+0200 lvl=eror msg="Request Completed" logger=context userId=0 orgId=0 uname= method=GET path=/login/generic_oauth status=500 remote_addr=127.0.0.1 time_ms=23 size=1768 referer="https://host.domain.com:8443/modules/monitoring/index.php/index/main?context=extNavButton_monitoring_1"
    t=2021-06-19T14:45:58+0200 lvl=eror msg=login.OAuthLogin(NewTransportWithCode) logger=context userId=0 orgId=0 uname= error="oauth2: cannot fetch token: 405 Method Not Allowed\nResponse: "
    t=2021-06-19T14:45:58+0200 lvl=eror msg="Request Completed" logger=context userId=0 orgId=0 uname= method=GET path=/login/generic_oauth status=500 remote_addr=127.0.0.1 time_ms=24 size=1768 referer="https://host.domain.com:8443/modules/monitoring/index.php/index/main?context=extNavButton_monitoring_1"
    t=2021-06-19T14:45:58+0200 lvl=eror msg=login.OAuthLogin(NewTransportWithCode) logger=context userId=0 orgId=0 uname= error="oauth2: cannot fetch token: 405 Method Not Allowed\nResponse: "
    t=2021-06-19T14:45:58+0200 lvl=eror msg="Request Completed" logger=context userId=0 orgId=0 uname= method=GET path=/login/generic_oauth status=500 remote_addr=127.0.0.1 time_ms=19 size=1768 referer="https://host.domain.com:8443/modules/monitoring/index.php/index/main?context=extNavButton_monitoring_1"
    t=2021-06-19T14:45:59+0200 lvl=eror msg=login.OAuthLogin(NewTransportWithCode) logger=context userId=0 orgId=0 uname= error="oauth2: cannot fetch token: 405 Method Not Allowed\nResponse: "
    t=2021-06-19T14:45:59+0200 lvl=eror msg="Request Completed" logger=context userId=0 orgId=0 uname= method=GET path=/login/generic_oauth status=500 remote_addr=127.0.0.1 time_ms=26 size=1768 referer="https://host.domain.com:8443/modules/monitoring/index.php/index/main?context=extNavButton_monitoring_1"
    t=2021-06-19T14:46:00+0200 lvl=eror msg=login.OAuthLogin(NewTransportWithCode) logger=context userId=0 orgId=0 uname= error="oauth2: cannot fetch token: 405 Method Not Allowed\nResponse: "
    t=2021-06-19T14:46:00+0200 lvl=eror msg="Request Completed" logger=context userId=0 orgId=0 uname= method=GET path=/login/generic_oauth status=500 remote_addr=127.0.0.1 time_ms=21 size=1768 referer="https://host.domain.com:8443/modules/monitoring/index.php/index/main?context=extNavButton_monitoring_1"
    t=2021-06-19T14:46:01+0200 lvl=eror msg="Alert Rule Result Error" logger=alerting.evalContext ruleId=49 name="Apache & PHP-FPM memory usage" error="request handler response error {invalid status code. status: 405 Method Not Allowed A <nil> [] [] 0xc00121de90}" changing state to=keep_state
    0
    Comment actions Permalink
  • Avatar
    Anastasia Zyrianova (Edited )

    Hello Milos Bajcetic,

    Thank you for bringing our attention to the issue! It was reproduced from our side. When redirecting all hosted domains to https://hostname.com:8443, Advanced Monitoring is not loading graphs. This part of the article has been hidden.

    The issue will be checked from our side. If possible, the solution in the article will be updated.

     

    0
    Comment actions Permalink
  • Avatar
    Steven Maas

    I would prefer to not redirect from ip to the host for security purposes. Is there a way to deny ip address :8443 requests instead? For example:

    https://203.0.113.2:8443 => Deny

    0
    Comment actions Permalink
  • Avatar
    Glenn

    This sort of works but we still get the SSL warning which you noted. Is there a way to redirect before the certificate check?

    0
    Comment actions Permalink
  • Avatar
    Anastasia Zyrianova

    Hello Glenn,

    For the following scenario: https://example.com:8443 => https://hostname.com:8443, if a regular domain is used, not Plesk technical domain, you may try accessing as http://example.com:8880. The redirect should be performed as expected. 


    0
    Comment actions Permalink

Please sign in to leave a comment.

Have more questions? Submit a request