ElectrumX server as a Tor hidden service I am trying to run an ElectrumX server on my PC. I run it on a docker container with the following Dockerfile configuration:
FROM python:3.7-alpine3.11
LABEL maintainer=&quot;Luke Childs &lt;lukechilds123@gmail.com&gt;&quot;

COPY ./bin /usr/local/bin
COPY ./VERSION /tmp

RUN VERSION=$(cat /tmp/VERSION) &amp;&amp; \
    chmod a+x /usr/local/bin/* &amp;&amp; \
    apk add --no-cache git build-base openssl &amp;&amp; \
    apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/v3.11/main leveldb-dev &amp;&amp; \
    apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing rocksdb-dev &amp;&amp; \
    pip install aiohttp pylru plyvel websockets python-rocksdb &amp;&amp; \
    git clone -b $VERSION https://github.com/kyuupichan/electrumx.git &amp;&amp; \
    cd electrumx &amp;&amp; \
    python setup.py install &amp;&amp; \
    apk del git build-base &amp;&amp; \
    rm -rf /tmp/*

VOLUME [&quot;/data&quot;]
ENV HOME /data
ENV ALLOW_ROOT 1
ENV DB_DIRECTORY /data
ENV SERVICES=tcp://:50001,ssl://:50002,wss://:50004,rpc://0.0.0.0:8000
ENV SSL_CERTFILE ${DB_DIRECTORY}/electrumx.crt
ENV SSL_KEYFILE ${DB_DIRECTORY}/electrumx.key
ENV HOST &quot;&quot;
WORKDIR /data

EXPOSE 50001 50002 50004 8000

CMD [&quot;init&quot;]


I want to advertise the ElectrumX server as a Tor hidden server. My bitcoin-core is also reachable by an .onion address: j3zla562edof65jn.onion. How can I configure the ElectrumX hidden server? What will be the .onion address of the server? I cannot access the ElectrumX from my electrum client using j3zla562edof65jn.onion address. Also, the status of the server is Closed in the Servers list.
Many Thanks.
I found the answer. It was not too hard. You should make a separate Tor hidden service for the ElectrumX server. The following two links helped me:

https://www.reddit.com/r/Electrum/comments/ggmduo/electrumx_over_tor_configuration_help/
https://en.bitcoin.it/wiki/Setting_up_a_Tor_hidden_service

To create a hidden service, you should take the following steps:

You must have tor (at least version 0.2.7.1) installed on your host. You don't need to install it on the docker container.
To establish a hidden service, open torcc file (probably you can find it at /etc/tor/torrc). Add these lines to the file:

HiddenServiceDir /var/lib/tor/electrumX_service/
HiddenServiceVersion 2
HiddenServicePort 50001 127.0.0.1:50001
HiddenServicePort 50002 127.0.0.1:50002


Restart tor by running this command: sudo service tor restart
To see the hostname of the new hidden service (electrumX_service), run sudo cat /var/lib/tor/electrumX_service/hostname. you will see the hostname. For example, my hostname is dpojvtzgm5dcg5ds.onion.
Now, you should set the REPORT_SERVICES environment variable in the ElectrumX container. To do this, you can set it at the beginning, when you want to run the container. I use the following command to run the container: (use the recently created hostname address for the REPORT_SERVICES environment variable.)

docker run --name=electrumx --rm --network=host -v /home/taghi/Taghi/docker-electrumx/electrumx:/data \
-e DAEMON_URL=http://MY_BITCOIN_CORE_USERNAME:MY_BITCOIN_CORE_PASSWORD@127.0.0.1:8332 \
-e COIN=BitcoinSegwit \
-e REPORT_SERVICES=tcp://dpojvtzgm5dcg5ds.onion:50001,ssl://dpojvtzgm5dcg5ds.onion:50002 \
lukechilds/electrumx


you can connect to the ElectrumX server by an Electrum client to check if it is working correctly. Furthermore, you can add it to this Server list .

Remember: I have exposed 50001, 50002, 50004, and 8000 ports in the above Dockerfile.